0

I am currently trying to get some documents from CouchDB with AngularJS. My server is running locally on localhost:5984, ans I cannot access it from Brackets' renderer.

The error is the following one:

XMLHttpRequest cannot load http://127.0.0.1:5984/generator/_all_docs. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:54142' is therefore not allowed access.

This error sounds well known and a real pain to deal with, and I already tried methods from this question and searched some other sources, but nothing seems to work. My CouchDB server looks like it is well configurated, with the following members inside its configuration properties:

[cors]
 credentials = false
 headers = accept, authorization, content-type, origin, referer, cache-control, x-requested-with
 methods = GET,PUT,POST,HEAD,DELETE
 origins = http://localhost


[httpd]
 enable_cors = true

I do not need credentials, at the moment, to access my data, I just need to access them from AngularJS. I would like to know what did I do / where did I go wrong, and if ever I did something wrong with my configuration or anything, how to finally allow my application to access those data. I know this is a CORS problem but as far as I tried, I found no way of doing so.

Thank you in advance !


EDIT

I am using CouchDB 1.6.1 and AngularJS, with Windows Seven. I did not try on other web browsers, but the problem currently happens with Google Chrome.

Community
  • 1
  • 1
Yassine Badache
  • 1,810
  • 1
  • 19
  • 38
  • Possible duplicate: http://stackoverflow.com/questions/20897033/how-to-add-cors-in-couchdb-no-access-control-allow-origin-header-is-present – The Head Rush Mar 23 '16 at 13:44
  • I already tried the ways described in this questions, as I mention it in my question, and they are not still working. I would just like to know if I forgot anything in my configuration, because everything seems correct ... – Yassine Badache Mar 23 '16 at 14:10
  • You have set allowable origins to `http://localhost`. According to the error provided is coming from `http://127.0.0.1:5984` -- but `localhost` != `127.0.0.1` even thought both refer to local machine. It should work if you change the config to allow requests from the actual address and port of the request origination. – The Head Rush Mar 23 '16 at 14:17

1 Answers1

0

Okay, so I solved the problem.

The solutions proposed in this topic are correct and solved the problem, but you must not fail while editing your fail. I'll explain:

When I first tried, I forgot a 's' in 'origins', and then suppressed my mistake it from the control panel. The control panel just suppresses the value, and not the original tag. When I tried again, this time by editing manually the local.ini file, I found this line:

origin = 

Which was, I guess, interfering with the good interpretation of the rest of the file. When I removed it, everything went smoothly

Problem solved, thanks to The Head Rush which pushed me on the way to victory with his commentary.

Community
  • 1
  • 1
Yassine Badache
  • 1,810
  • 1
  • 19
  • 38