DEV Community

Discussion on: Using Create-React-App with Express

Collapse
 
thomasgauvin profile image
Thomas Gauvin

leaving this here for anyone that might be encountering the same issue! Here's how I fixed it, I just needed to add a route that matches any (*) that don't match exactly '/', and serve the react app:

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

// Handles any requests that don't match the ones above
app.get('*', (req,res) =>{
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

Cheers!

Collapse
 
i3ats profile image
i3ats

(*) did the trick for me too :)