Getting error "CORS request rejected: ... : ...@localhost:5984/db_name"

94 views
Skip to first unread message

Ami Kapadia

unread,
Dec 22, 2014, 12:31:45 PM12/22/14
to mobile-c...@googlegroups.com
Hi!

I am using CBL in iOS. It's working but when I use same code in Android, CBLite is initialised properly but 
When I send HTTP request using following code : 
var xmlHttp = new XMLHttpRequest()
xmlHttp.open('GET', url, false)
xmlHttp.send(null)
I am getting following error : 
"XMLHttpRequest Exception 101"

And when I try to config db, I am getting this error : 
"CORS request rejected: ... : ...@localhost:5984/db_name" 

Any idea how I can solve this?

Thanks!
Ami

Ami Kapadia

unread,
Dec 22, 2014, 4:21:52 PM12/22/14
to mobile-c...@googlegroups.com
I am using PhoneGap CouchBaseLite plugin referred from this - https://github.com/couchbaselabs/TodoLite-PhoneGap.
Any solution for CORS error?

Jens Alfke

unread,
Dec 22, 2014, 6:26:19 PM12/22/14
to mobile-c...@googlegroups.com

On Dec 22, 2014, at 1:21 PM, Ami Kapadia <ami....@gmail.com> wrote:

And when I try to config db, I am getting this error : 
"CORS request rejected: ... : ...@localhost:5984/db_name" 

Sorry, our main PhoneGap guy is out sick and not answering emails.

I'm not an expert, but I'm pretty certain that 5984 is the wrong port. Generally CBL on Android will bind to an OS-selected (i.e. random) port number. Are you sure you're using the API URL you got from the cblite.getURL() callback?

(5984 is the port CouchDB uses, so you might have some hard-coded CouchDB URL references in your code.)

—Jens

Ami Kapadia

unread,
Dec 25, 2014, 8:05:04 AM12/25/14
to mobile-c...@googlegroups.com
Hi Jems!
Thanks for your response!

On Tuesday, December 23, 2014 4:56:19 AM UTC+5:30, Jens Alfke wrote:

On Dec 22, 2014, at 1:21 PM, Ami Kapadia <ami....@gmail.com> wrote:

And when I try to config db, I am getting this error : 
"CORS request rejected: ... : ...@localhost:5984/db_name" 

Sorry, our main PhoneGap guy is out sick and not answering emails.

I'm not an expert, but I'm pretty certain that 5984 is the wrong port.
I am getting this port for Android and it was working fine in my previous app. But then I have changed my CBLite config file and now it's having bug. So, I am sure that this is not an issue of port number.
 
Generally CBL on Android will bind to an OS-selected (i.e. random) port number. Are you sure you're using the API URL you got from the cblite.getURL() callback?
Yes, I am using that. I debugged app and  CBL is initialised on "localhost:5984/" port only.
Reply all
Reply to author
Forward
0 new messages