1

我正在从 jquery 调用休息服务并收到以下 CORS 错误。我可以通过仅更改 jquery 请求的标头而不是更改服务器端的任何内容来解决此问题吗?

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
4

2 回答 2

0

在客户端上更改它的唯一方法是使用:

--disable-web-security 

chrome浏览器中的参数。没有其他东西对我有用。

对于较新版本的 Chrome:

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

然后你也可以添加

--test-type

以防止弹出警告。

当 chrome 启动时,所有这些都应该作为标志添加。您可以在创建快捷方式然后将它们附加到Target路径中后将它们作为参数添加。

于 2016-04-19T04:40:08.053 回答
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.

于 2015-08-03T15:10:55.887 回答