Skip to content

Instantly share code, notes, and snippets.

@rajeshdavidbabu
Created May 20, 2018 18:07
Show Gist options
  • Save rajeshdavidbabu/2bafe3d621d61076abfc39c01f3de5dc to your computer and use it in GitHub Desktop.
Save rajeshdavidbabu/2bafe3d621d61076abfc39c01f3de5dc to your computer and use it in GitHub Desktop.
Server.js for heroku deployment
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