Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- // Serve the static files from the React app
- app.use(express.static(path.join(__dirname, 'react/build')));
- // Routers etc. here
- ...
- // Handles any requests that don't match the ones above
- app.get('*', (req,res) => {
- res.sendFile(path.join(__dirname+'/react/build/index.html'));
- });
- // If Heroku
- "scripts": {
- "start": "node index.js",
- "heroku-postbuild": "cd react && npm install --only=dev && npm install && npm run build",
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment