Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

javascript - 如何解决“重定向已被CORS策略阻止:没有“ Access-Control-Allow-Origin”标头”?(How to solve 'Redirect has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header'?)

I am working on a app using vue js.(我正在使用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.(但是当我的应用程序点击url时,显示以下消息。)

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.(无法加载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'标头存在于请求的资源上。)

Origin ' http://localhost:8080 ' is therefore not allowed access.(因此,不允许访问源' http:// localhost:8080 '。)
  ask by Sharat translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:(除了awd提到的有关让负责服务器的人员进行重新配置(本地开发的不切实际的解决方案)外,我还使用了类似更改的chrome插件:)

https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbc(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 .(您可以将local dev server (ex: localhost:8080)显示为来自172.16.1.157:8002 or any other domain 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...