Created
August 22, 2021 09:59
-
-
Save artyomsveshnikov/26059518ed2f64bdfd8e2bd10fa90157 to your computer and use it in GitHub Desktop.
Simple server.js for React static site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Install express server | |
const express = require('express'); | |
const path = require('path'); | |
const app = express(); | |
// Serve only the static files form the dist directory | |
app.use(express.static(__dirname + '/build')); | |
app.get('/*', function(req,res) { | |
res.sendFile(path.join(__dirname+'/build/index.html')); | |
}); | |
// Start the app by listening on the default Heroku port | |
app.listen(process.env.PORT || 8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment