更新时间:2022-10-14 18:45:39
除了awd提到的让服务器负责人重新配置(一个不切实际的本地开发解决方案)之外,我使用了一个更改像这样的-origin chrome插件:
https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbc
您可以使本地开发服务器(例如:localhost:8080)
看起来来自 172.16.1.157:8002或任何其他域
。
I am working on a app using vue js. According to my setting I have need to pass to variable to my url when setting changed.
$.get('http://172.16.1.157:8002/firstcolumn/' + c1v + '/' + c1b, function (data) {
// some code...
});
but when my app hit on url, it shows following messsge.
Failed to load http://172.16.1.157:8002/firstcolumn/2017-03-01/2017-10-26: Redirect from 'http://172.16.1.157:8002/firstcolumn/2017-03-01/2017-10-26' to 'http://172.16.1.157:8002/firstcolumn/2017-03-01/2017-10-26/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
In addition to what awd mentioned about getting the person responsible for the server to reconfigure (an impractical solution for local development) I use a change-origin chrome plugin like this:
https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbc
You can make your local dev server (ex: localhost:8080)
to appear to be coming from 172.16.1.157:8002 or any other domain
.