Skip to content

Instantly share code, notes, and snippets.

@rkumar1904
Created November 6, 2020 06:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rkumar1904/db6f7f5f7542ca6b86f5c8b8733860e3 to your computer and use it in GitHub Desktop.
keep this file in project root dir
const express = require('express');
const path = require('path');
const compression = require('compression');
const port = process.env.PORT || 9000;
const app = express();
app.use(compression());
app.use(express.static(path.join(__dirname, '/dist')));
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, '/dist', 'index.html'));
});
app.listen(port, (err) => {
if (!err) {
console.log('Listening on port', port);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment