[Vuejs]-Vue Js public Websocket blocked by CORS policy

0👍

The real problem in this case, is to try to connect to other domain from the client side and the server do not allow “Access-Control-Allow-Origin”.

The best solution for this question is follow the arquiteture of project bellow:

https://github.com/Tucsky/SignificantTrades

In resume, implement conection websocket in server side and expose a local websocket in the client side.

In my case, Node and Vue js.

2👍

Try installing this node package named cors-server that will start a web server on a given port that will proxy any request received and add CORS headers to it.

To start the server simply call it from the command line and supply a port number

cors-server <port>

After that, any requests sent to http://localhost:[port] will have Access-Control-Allow-Origin: * on the response.

e.g:

POST http://localhost:3005/http://www.google.com

Hope this helps!.

Leave a comment