AreWe

Untitled

Mar 31st, 2021
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2.  
  3. // Serve the static files from the React app
  4. app.use(express.static(path.join(__dirname, 'react/build')));
  5.  
  6. // Routers etc. here
  7. ...
  8.  
  9. // Handles any requests that don't match the ones above
  10. app.get('*', (req,res) => {
  11.     res.sendFile(path.join(__dirname+'/react/build/index.html'));
  12. });
  13.  
  14. // If Heroku
  15. "scripts": {
  16.     "start": "node index.js",
  17.     "heroku-postbuild": "cd react && npm install --only=dev && npm install && npm run build",
  18.     ...
  19.   }
Advertisement
Add Comment
Please, Sign In to add comment