How to solve the problem of CORS policy blocking redirects
P粉824889650
2023-08-21 11:11:10
<p>I'm developing an application using <code>Vue js</code>.
Based on my setup, I need to pass a variable 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 application accesses the URL, the following message is displayed. </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 CORS policy blocking: There is no 'Access-Control-Allow-Origin' header on the requested resource. Therefore, access to source 'http://localhost:8080' is not allowed. </pre></p>
Thanks to everyone, I solved the problem with this extension on my Chrome browser.
Allow CORS: Access-Control-Allow-Origin
In addition to what awd mentioned about having the person responsible for the server reconfigure (an impractical solution for local development), I use the change source chrome plugin like this:
Moesif Orign & CORS Changer(used to be free, now requires work email address >_>)You can make your
local development server (eg: localhost:8080)
appear to come from172.16.1.157:8002 or any other domain name
.