Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sockjs-node Cross-Origin Request Blocked warnings after terminating webpack running Vue.js with Ctrl+C

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!

like image 373
pure_Redwood Avatar asked Jul 16 '20 22:07

pure_Redwood


1 Answers

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.

like image 76
aroundtheworld Avatar answered Nov 12 '22 06:11

aroundtheworld