I need to access a remote CouchDB hosted on smileupps. I am having trouble with CORS. How do I configure it to allow any device to post documents using basic authentication? I know I need to set Access-Control-Allow-Credentials
to true
, but then what about Access-Control-Allow-Origin
? I can't use *
but I need to be able to connect to any device. On the client side I can't use any library, just ajax.
Asked
Active
Viewed 187 times
0

Jonathan Hall
- 75,165
- 16
- 143
- 189

savram
- 500
- 4
- 18
-
See the answer at https://stackoverflow.com/a/42742360/441757. couchdb intentionally provides no supported way to do what you’re trying to do. – sideshowbarker Jun 20 '18 at 15:48
1 Answers
0
Your CouchDB installation needs to have CORS configured so that it puts out the correct headers to allow "ajax" requests to be allowed from your browser to your CouchDB server.
The CORS configuration instructions are in the CouchDB documentation. In short:
[httpd]
enable_cors = true
[cors]
credentials = true
origins = *
methods = GET,POST,PUT,DELETE
Easier still is the "Enable CORS" button in the CORS section of the CouchDB dashboard:

Glynn Bird
- 5,507
- 2
- 12
- 21
-
I can't have origins set to `*` when credentials are set to `true`. See "Credentialed requests and wildcards" here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS – savram Jun 19 '18 at 16:04