How to fix "Redirect blocked by CORS policy: No 'Access-Control-Allow-Origin' header"?
P粉420958692
2023-08-23 13:18:14
<p>I'm developing an application using <code>Vue js</code>.
Based on my setup, I need to pass variables to my URL when the settings change. </p>
<pre class="lang-js prettyprint-override"><code><!-- language: lang-js -->
$.get('http://172.16.1.157:8002/firstcolumn/' c1v '/' c1b, function (data) {
// some code...
});
</code></pre>
<p>But when my app clicks on the URL, it displays the following message. </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>
Thank you everyone, I solved it through this extension on Chrome.
Allow CORS: Access-Control-Allow-Origin一个>
In addition to having the person responsible for the server reconfigure as awd mentioned (an impractical solution for local development), I also used a change source chrome plugin like this:
Moesif Orign and CORS Converter(used to be free but now want a work email address>_>)You can make your
local development server (eg: localhost:8080)
appear to be coming from172.16.1.157:8002 or any other domain
.