Api Socket CORS

juanmales2 years ago

Hi,
Im trying to access to api/socket after create session cookie but its impossible for me.
This is only happening with the Websocket, because I can use the API.
The console says that its a CORS problem, and I can see in request’s headers that Access-Control-Allow-Origin doesnt exist.
I added <entry key web.origin>*</entry> like I saw in this forum, but it doesnt work. Can you help me please?

I can see when I use the endpoint in my browser (mydomain.com/api/socket) I receive a 405 error: Method not allowed.

Anton Tananaev2 years ago

Maybe you're not doing the request correctly?

juanmales2 years ago

Maybe…

Im doing tests before the integration.
I did something like fetch(“https://domain/api/socket”, {method: “GET”, credentials: “include”}).
I think that the problem is in server side, but im not sure.
I tried to add headers (Access-Control-Allow-Origin) with proxy (Im using Nginx) but the headers doesnt appear in the response (maybe im not doing it correctly) :(.

Anton Tananaev2 years ago

You should probably do a bit of research on how to use WebSocket.

juanmales2 years ago

You are right. I have been using socket.io for a long time and I just realized what im doing…
Thanks for redirect my way!