Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add cors in couchDB -- No 'Access-Control-Allow-Origin' header is present on the requested resource

Tags:

I am trying to create a html file which synchronize data from a pouchDb to couchDb ..but iam getting the following error in chrome console.

Uncaught TypeError: Cannot call method 'addEventListener' of null

OPTIONS http://localhost:5984/todos/ 405 (Method Not Allowed)

OPTIONS http://localhost:5984/todos/ No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. XMLHttpRequest cannot load http://localhost:5984/todos/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. OPTIONS http://localhost:5984/todos/ No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. pouchdb-nightly.js:3496 OPTIONS http://localhost:5984/todos/ No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. pouchdb-nightly.js:3496 XMLHttpRequest cannot load http://localhost:5984/todos/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

I found a way to avoid this issue. That is i have to open chrome using the below command: cd C:\Program Files (x86)\Google\Chrome\Application Chrome.exe --disable-web-security.But this didn't solve the issue. I saw a lot of similar question here.but i didn't understand any answer since i am relatively new in this field

like image 689
ess Avatar asked Jan 03 '14 05:01

ess


1 Answers

From this documentation:

To enable CORS support, you need to set the enable_cors = true option in the [httpd] section of local.ini, and add a [cors] section containing a origins = * setting. Note that by default, no origins are accepted; you must either use a wildcard or whitelist.

[httpd]
enable_cors = true

[cors]
origins = *
like image 125
robertc Avatar answered Sep 20 '22 15:09

robertc