corsionic2couchdbjelastic

CORS issue with CouchDB + credentials + origin wildcard


I am trying to move from Cloudant to Jelastic on flow.ch. I am getting CORS errors with pouchdb when testing locally (ionic serve).

Is there any other configuration in Jelastic besides CouchDB I am missing?

XMLHttpRequest cannot load http://xxx.flow.ch/xxx. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8100' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  1. I configured a CouchDB on Jelastic and activated CORS. enter image description here enter image description here

  2. Normal access via CURL works. Replication from Cloudant to Jelastic worked as well.

  3. I tried to use a Chrome extension to enable "Allow-Control-Allow-Origin: *"


Solution

  • The couchdb docs say this:

    You can’t set origins = * and credentials = true option at the same time

    So if you want cross-origin requests with credentials to work with couchdb, you must set the origins value to an explicit list of allowed origins; for example:

    [cors]
    origins = http://localhost, https://localhost, http://couch.mydev.name:8080