Skip to content

Instantly share code, notes, and snippets.

@velopert
Last active January 15, 2017 03:57
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 velopert/3e4094b4208a6124a310181fa9f72017 to your computer and use it in GitHub Desktop.
Save velopert/3e4094b4208a6124a310181fa9f72017 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const path = require('path');
app.use('/', express.static(path.resolve(__dirname, '../build')));
app.get('*', (req, res, next) => {
if(req.path.split('/')[1] === 'static') return next();
res.sendFile(path.resolve(__dirname, '../build/index.html'));
});
app.listen(4000, function () {
console.log('Example app listening on port 4000!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment