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
From this documentation:
To enable CORS support, you need to set the
enable_cors = true
option in the[httpd]
section oflocal.ini
, and add a[cors]
section containing aorigins = *
setting. Note that by default, no origins are accepted; you must either use a wildcard or whitelist.[httpd] enable_cors = true [cors] origins = *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With