Couchbase cors config json

hi all
i’m trying to configure cors adding this element json:
“CORS”: {
“Origin”:[""],
“LoginOrigin”:[“http://localhost:8000”],
“Headers”:[“Content-Type”],
“MaxAge”: 1728000
},
in gateway config.
but from device i got this error:
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’.

To authenticate users with CORS, the domain must be explicitly specified in Origin and LoginOrigin (i.e * can’t be used with user auth). The documentation has been updated to be more specific on this topic https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/config-properties/index.html#CORS.

James

Hi Jamiltz,

Can you give me an example of CORS to use in sync_gateway_config.json file ?

“CORS”: {
“Origin”:[“http://localhost:4985”],
“LoginOrigin”:[“user1”,“user2”],
“Headers”:[“Content-Type”],
“MaxAge”: 1728000
},

image

My config file looks like this right now:

  "log": ["*"],
  "configServer": "http://couchdbp:8091/",
  "adminInterface": ":4985",
  "databases": {
    "getting-started-db": {
      "server": "http://couchdbp:8091",
      "bucket": "staging",
      "username": "sync_gateway",
      "password": "gateway#123",
      "enable_shared_bucket_access": true,
      "import_docs": "continuous",
      "num_index_replicas": 0,
      "users": {
        "GUEST": { "disabled": false, "admin_channels": ["*"] }
      },
      "sync": `function (doc, oldDoc) {
        if (doc.sdk) {
          channel(doc.sdk);
        }
      }`
    }
  }
}
~

Refer to these docs for an example

1 Like