如何解决“重定向已被 CORS 策略阻止:没有“Access-Control-Allow-Origin”标头”?
P粉420958692
P粉420958692 2023-08-23 13:18:14
[Vue.js讨论组]
<p>我正在使用 <code>Vue js</code> 开发一个应用程序。 根据我的设置,我需要在设置更改时将变量传递给我的 URL。</p> <pre class="lang-js prettyprint-override"><code>&lt;!-- language: lang-js --&gt; $.get('http://172.16.1.157:8002/firstcolumn/' + c1v + '/' + c1b, function (data) { // some code... }); </code></pre> <p>但是当我的应用程序点击 URL 时,它会显示以下消息。</p> <pre class="brush:php;toolbar:false;">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.</pre> <p><br /></p>
P粉420958692
P粉420958692

全部回复(2)
P粉239089443

谢谢大家,我通过 Chrome 上的这个扩展解决了。

允许 CORS:Access-Control-Allow-Origin一个>

P粉748218846

除了 awd 提到的让负责服务器的人员重新配置(本地开发的不切实际的解决方案)之外,我还使用了这样的更改源 chrome 插件:

  1. Moesif Orign 和 CORS 转换器(以前是免费的,但现在想要一个工作电子邮件地址>_>)
  2. 允许 CORS:Access-Control-Allow-Origin(2023 年测试)

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号