Chintan Shah
Chintan Shah

Reputation: 81

CORS issue when using PouchDB to access Cloudant

I'm using PouchDB to access Cloudant No SQL Service available in Bluemix. However, I get the following error when I run my web app in browser:

XMLHttpRequest cannot load https://6989a1bd-71a1-4ca1-b46e-3b1352db6b99-bluemix.cloudant.com/carpooldb/?_nonce=1452076315442. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8080' is therefore not allowed access.

I've enable CORS in Cloudant and my CORS config looks like this,

{
  "enable_cors": true, 
  "allow_credentials": true, 
  "origins": [
    "*"
  ]
}

Upvotes: 3

Views: 1015

Answers (1)

Bradley Holt
Bradley Holt

Reputation: 618

Instead of allowing all domains (using the * wildcard), try restricting to specific domains/origins and include http://localhost:8080 (without a trailing slash) in the list.

Upvotes: 1

Related Questions