2
votes

I have CORS enabled in CouchDB: enter image description here

enter image description here

I run the app on Windows 8.1, serving it with hapi.js.

When viewing it in Chrome after a while this error message appears in the console:

Uncaught (in promise) CustomPouchError {status: 500, name: "unknown_error", message: "Database encountered an unknown error", error: true, toString: function}

Firefox aborts accessing CouchDB, for instance: http://127.0.0.1:5984/user_z_at_z_p_ch/?_nonce=1431328831527, then reports that a cross origin request was blocked.

I have tried to run add-cors-to-couchdb but I get this error:

PS C:\Users\alex> add-cors-to-couchdb
events.js:85
      throw er; // Unhandled 'error' event
        ^
Error: read ECONNRESET
    at exports._errnoException (util.js:746:11)
    at TCP.onread (net.js:559:26)
2

2 Answers

1
votes

Your CORS settings look correct. Are you sure your CouchDB is externally accessible from the hostname/port you're using?

If add-cors-to-couchdb is failing, it's because the default CouchDB at localhost:5984 is inaccessible. It has options to specify a CouchDB at another URL.

0
votes

it seems that I missed one header in the cors section of config.ini in couchdb: x-csrf-token

cors now works with these headers:

accept, authorization, content-type, origin, referer, x-csrf-token

I have no idea why this happens but hey: it works