Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
113
rated 0 times [  116] [ 3]  / answers: 1 / hits: 22252  / 11 Years ago, fri, january 3, 2014, 12:00:00

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)GoogleChromeApplication 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


More From » html

 Answers
13

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 = *


[#73407] Thursday, January 2, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blaisep

Total Points: 748
Total Questions: 95
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
blaisep questions
Wed, Dec 16, 20, 00:00, 4 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
Tue, Nov 12, 19, 00:00, 5 Years ago
Mon, Nov 11, 19, 00:00, 5 Years ago
;