Working with Django and Vue.js for an application. I'm running the website on https://localhost:8000 and the frontend on port 8080 as a local https grid instance. Before setting up headers, I kept getting CORS errors of this type for every HTTP request:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]
This was fixed by appending the following headers in the webpack config file:
headers: {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
},
I likewise added https with the key, certificate, and certificate authority.
After this, the errors largely went away. However, whenever I Ctrl+C my development server, I get the above error in increments of 1-2-4-8-16-32-64-128-... seconds like so:
[WDS] Disconnected!
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]
Is this normal behavior? Is this some kind of Keep-Alive that CORS sends?
Any help would be appreciated.
Thank you!
For me running npm run build
/ vue-cli-service build
and then restarting the serve
process fixes this.
It seemed to happen for me when switching the network I was working from - not totally sure what the exaplanation is though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With