a year ago
Hi!
I am trying to connect to my server and I have cors set up. However, when i try to connect to it, I get 503 Service Unavailable. I have looked into every resource at it looks like there is no issue with the implementation. The console logs:
Access to XMLHttpRequest at 'FRONTEND' from origin 'SERVER' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
polling.js:298
GET FRONTEND/socket.io/?EIO=4&transport=polling&t=O8y3jC net::ERRFAILED 503 (Service Unavailable)
The server:
const app = express();
app.use(cors());
const server = createServer(app);
const io = socketIo(server, {
cors: {
origin: "FRONTEND",
methods: "*",
credentials: true
}
});
I have been struggeling with this for a while now and I really need it to work. Everything works in development. Please help.
1 Replies
a year ago
Please read this docs page -
https://docs.railway.app/guides/fixing-common-errors
Your websocket server and http server need to be both on the same listener and port.