如何解决'重定向已被CORS策略阻止:没有'Access-Control-Allow-Origin'标题'? [英] How to solve 'Redirect has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header'?

查看:33633
本文介绍了如何解决'重定向已被CORS策略阻止:没有'Access-Control-Allow-Origin'标题'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vue js开发应用程序。
根据我的设置,我需要在设置更改时将变量传递给我的url。

  $ .get('http://172.16.1.157:8002/firstcolumn/'+ c1v +'/'+ c1b,function(data){
// some code ...
});

但当我的应用程序点击url时,会显示以下消息。


无法加载 http://172.16.1.157:8002/firstcolumn/2017-03-01/2017-10-26 :从' http://172.16.1.157:8002/firstcolumn/2017-03-01/2017-10-26 '到' http://172.16.1.157:8002/firstcolumn/2017-03- 01 / 2017-10-26 / 已被CORS策略阻止:请求的资源上没有Access-Control-Allow-Origin标头。因此,不允许访问 http:// localhost:8080



解决方案

除了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.

这篇关于如何解决'重定向已被CORS策略阻止:没有'Access-Control-Allow-Origin'标题'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆