Hello, I am a beginner developer who has just finished my first react project. I created a multiplayer chess application that uses socket.io as a “backend” to send requests from two different clients and tell them about the state of the game, move the pieces, set up a win condition and reload when players leave.
This all works on the localhost in react. However I am having some issues getting it to work when I host it to render. I am positive I am messing some sort of setting up. I tried using the the static site option that render has. However while it loads my front end correctly. My backend service doesn’t seem to work.
I tried to fix it by using a web service and then utilizing npm install; npm run build for my (I don’t have much familiarity with yarn) for my build command.
Then for the start command I added my npm run “startServer” script that I created in my package.json (“node multiplayer_chess_backend/src/index.js”).
However I got a “CANNOT GET /” error when I attempted this.
I managed to get a production react app running locally on it’s default port with npx serve -s build
However I heard that you need to use a static server for it to work with render?
How would I deploy a static server for a react app? Also how would I utilize socket.io if I only had a static server, wouldn’t I need a web service as well? How would I combine both static server and web service? I heard it’s possible to use monorepository with render.yaml files. But I am a bit confused by the documentation.
I am probably making some simple mistake, but I genuinely wish to improve, and would greatly appreciate if someone could help me solve this problem.
Thanks for your time,
-Evan