Put /* in app.get
When using react client-side routing and serving production build from nodejs. The server crashes on any client side route because we are not mapping anything to that route from server like /room0 does not have any definition in server.js because we only defined / route which send index.html right now.
The best solution to this issue is to put /* rather than putting only /. It will send index.html in all requested routes which will look something like this:
app.get("/*", function(request, response){ response.sendFile(path.resolve(__dirname, "../client-web/build", "index.html")); });
Put /* in app.get
When using react client-side routing and serving production build from nodejs. The server crashes on any client side route because we are not mapping anything to that route from server like /room0 does not have any definition in server.js because we only defined / route which send index.html right now.
The best solution to this issue is to put /* rather than putting only /. It will send index.html in all requested routes which will look something like this:
app.get("/*", function(request, response){ response.sendFile(path.resolve(__dirname, "../client-web/build", "index.html")); });