I’m trying to access data from sync gateway REST API (get document) from an Angular web app authenticating with the SyncGatewaySession, but I’m unable to get it working.
The following cURL statement is working:
curl -X GET 'https://myserver.cloud:4984/bucket/docID' -H 'Accept: application/json' -H 'Cookie: SyncGatewaySession=d29cf8e88a005df9bf9ae1438ff50c0173310a15'
but when I try to replicate the same call in browser JS, the browser omits to add the cookie header because is not specified by Access-Control-Allow-Headers header in OPTIONS of sync gateway API. The OPTIONS specifies the following values;
**Access-Control-Allow-Headers**: Content-Type, SyncGatewaySession, Authorization, Access-Control-Allow-Headers, withCredential, Access-Control-Allow-Credentials
so I’ve tried to add the header called SyncGatewaySession, like this:
the header is now sent by the browser but I got 401 - Unauthorized response (same sending header with cURL)
Even adding “Cookie” to CORS Access-Control-Allow-Headers section of sync gateway config didn’t help.