PDA

View Full Version : No 'Access-Control-Allow-Origin' header is present on the requested resource



simbad
27 Mar 2014, 10:42 AM
Hi,
I am trying to make an ajax request to get some data to the app. The problem is that when i am make the request the following error occurs.

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost (http://localhost/)' is therefore not allowed access.

here is the config in the server side :
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: orgin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
Access-Control-Allow-Methods: GET,POST,DELETE,OPTIONS

and here is the ajax request:

Ext.Ajax.request({
url: url,
method: 'post',
params: {
origin:origin_data
},

scottmartin
28 Mar 2014, 7:03 AM
Here is some info:
http://stackoverflow.com/questions/16046364/origin-http-localhost-is-not-allowed-by-access-control-allow-origin

snehalmasne
27 May 2015, 10:50 PM
Chrome does not support localhost for CORS requests.To get around this you can start chrome with the `--disable-web-security` flag (assuming you're just testing).

f.baron
27 May 2015, 11:09 PM
You can add correct headers this way:


Ext.Ajax.request({
useDefaultXhrHeader: false,
cors: true,
url: url,
method: 'POST',