-
Fix the route when necessary
-
Run
npm init
yarn add express
node index.js
const path = require("path"); | |
const express = require("express"); | |
const app = express(); | |
const PORT = process.env.PORT || 3000; | |
app.use(express.static(path.join(__dirname, "..", "build"))); | |
app.get("/*", function(req, res) { | |
res.sendFile( | |
path.join(__dirname, __dirname, "..", "build", "index.html") | |
); | |
}); | |
app.listen(PORT, (req, res) => { | |
console.log(`The server is up on port ${PORT}`); | |
}); |