1

I am calling a rest service from jquery and getting the below CORS error. Can I fix this by just changing the header of jquery request rather than by changing anything in the server side?

XMLHttpRequst cannot load  https://myservice.com/api/myservice/?pos=project  'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost/2234' is therefore not allowed access. The response had HTTP status code 502
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197

2 Answers2

0

The answer is no. CORS is configured on the server side. There is nothing the client can do to circumvent this (doing so would defeat the point of this security measure). If the server exposes a jsonp-enabled endpoint that is not subject to CORS, you could work with that without making server-side CORS configuration changes.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
0

The only way you can change it on the client is by using :

--disable-web-security 

argument in a chrome browser. Nothing else have worked for me.

For the newer versions of Chrome :

--disable-web-security --user-data-dir 

Then you can also add

--test-type

to prevent the warning popups.

All these should be added as flags when chrome is started. You can add them as parameters, after creating a shortcut and then appending these in Target path.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108