UNPKG

dg-npm-templates

Version:

Npx generator for react app dependency creation by digite

22 lines (20 loc) 660 B
const express = require('express'); const bodyParser = require('body-parser') const cors = require('cors') const path = require('path'); const app = express(); app.disable('x-powered-by'); app.use(express.static(__dirname)); app.use(cors()) // need to declare a "catch all" route on your express server // that captures all page requests and directs them to the client // the react-router do the route part app.get('*', function (req, res) { res.sendFile(path.join(__dirname, 'index.html')); }); app.listen( process.env.PORT || 5000, function () { console.log(`Frontend start on http://localhost:5000`) } );