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

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

问题描述

我正在使用 Vue js 开发一个应用程序.根据我的设置,我需要在设置更改时将变量传递给我的 URL.

I am working on an app using Vue js. According to my setting I need to pass to a variable to my URL when setting change.

<!-- language: lang-js -->

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

但是当我的应用点击 URL 时,它显示以下消息.

But when my app hit on URL, it shows the following message.

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.

推荐答案

除了 awd 提到的让负责服务器的人重新配置(本地开发的一种不切实际的解决方案)之外,我还使用了一个 change-origin chrome 插件,例如这个:

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:

Moesif Orign &CORS 转换器

您可以使您的本地开发服务器(例如:localhost:8080) 看起来来自172.16.1.157:8002 或任何其他域.

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天全站免登陆