Cors errors Nodejs + Angular + Railway Deploy #4676
-
Hi, Im stuck for several weeks triying socket io works when I deploy the back in cloud. Here is my back: io.on('connection', (socket) => { Here the Service with Angular: export class SocketService { The errors: Access to XMLHttpRequest at 'https://socketchatsemilla.up.railway.app/socket.io/?EIO=4&transport=polling&t=OSkgJlF' from origin 'http://localhost:4200' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. GET https://socketchatsemilla.up.railway.app/socket.io/?EIO=4&transport=polling&t=OSkgJlF net::ERR_FAILED 200 Im literally getting crazy. Tried with Vercel and the same. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! I think it's const io = require('socket.io')(htpp, {
cors: {
origin: ["http://localhost:4200"],
credentials: true,
allowedHeaders: ["my-custom-header"],
}
}); |
Beta Was this translation helpful? Give feedback.
Hi! I think it's
origin
, notorigins
in thecors
option:Reference: https://socket.io/docs/v4/server-options/#cors