Skip to content

Instantly share code, notes, and snippets.

@JosepRoo
Created October 28, 2019 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosepRoo/a502f207fb20f9f31275635ddbec6678 to your computer and use it in GitHub Desktop.
Save JosepRoo/a502f207fb20f9f31275635ddbec6678 to your computer and use it in GitHub Desktop.
//Install express server
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/dist/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