Created
May 20, 2018 18:07
-
-
Save rajeshdavidbabu/2bafe3d621d61076abfc39c01f3de5dc to your computer and use it in GitHub Desktop.
Server.js for heroku deployment
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
const express = require('express'); | |
const path = require('path'); | |
const port = process.env.PORT || 8080; | |
const app = express(); | |
// the __dirname is the current directory from where the script is running | |
app.use(express.static(__dirname)); | |
// send the user to index html page inspite of the url | |
app.get('*', (req, res) => { | |
res.sendFile(path.resolve(__dirname, 'index.html')); | |
}); | |
app.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment