Hey everyone, I am trying to deploy my first ever web application which is an online multiplayer pictionary game similar to the website skribblio. I am using socket.io for the first time to accomplish this.
Although I was able to run my project perfectly fine locally on localhost3000, I am having some CORs problems when switching over to a public deployment. Specifically, in my console I am getting the error:
From the googling I did on this general issue, I found stuff related to redirects, headers, and netlify.toml which I tried to follow but found no success. Can anyone help me solve this issue please? Thanks.
EDIT: After making these changes, I am now getting a new, similar error:
blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Correct me if I am wrong, but I believe my socket server being hosted on Railway. Unless I have a poor understand of how the Netlify front end is being connected with the Railway backend.
Sorry, I missed that as I only skim read what you had posted, you’d be suprised how frequently this question comes up where the person is trying to host the socket server on Netlify.
In your case if the client side code is connecting directly to the socket server on Railway, then the connection is between the users browser and railway and has nothing to do with Netlify (unless you’re proxying those requests via a redirect).
Edit: Just a heads up that the URL you’ve provided for the live deployment of the front-end doesn’t load for me either, so I can’t actually see the cors error that you’re encountering on the front-end.