Search code examples
couchdbcouchbasepouchdbcouchbase-sync-gateway

Syncing PouchDB and Couchbase Sync Gateway - CORS Error


I need help syncing PouchDB with Couchbase Sync Gateway.

I keep getting the following error that points to a CORS problem, but I've configured Couchbase Sync Gateway (CSG) for CORS according to their documentation.

XMLHttpRequest cannot load http://localhost:4985/test-database/.
No 'Access-Control-Allow-Origin'header is present on the requested
resource. Origin 'http://localhost:3000' is therefore not 
allowed access.

I've tried the following config file per the CSG docs:

http://developer.couchbase.com/documentation/mobile/1.2/develop/guides/sync-gateway/configuring-sync-gateway/config-properties/index.html

{
  "log": ["HTTP+"],
  "CORS": {
    "origin":["http://localhost:3000"],
    "loginOrigin":["http://localhost:3000"],
    "headers":["Content-Type"],
    "maxAge": 1728000
  },
  "databases": {
    "test-database": {
      "server": "walrus:",
      "users": { "GUEST": {"disabled": false, "admin_channels": ["*"] } }
    }
  }
}

I've tried other config files as well from the Couchbase blog, but none of them work! Any help with this will be greatly appreciated!


Solution

  • It looks like you're trying to hit the Sync Gateway admin port, which doesn't support CORS, as far as I know. Have you tried targeting the public port (4984)?