Skip to content

Instantly share code, notes, and snippets.

Last active Aug 10, 2017
What would you like to do?
Angular Universal Express Sample
import { angularUniversal } from 'angular-universal-express';
import * as express from 'express';
const app = express();
I usually copy my Angular CLI "dist" build into my "dist-server" build
and serve them as static files so they aren't treated as dynamic routes.
app.use(express.static(__dirname + '/dist'));
app.get('/*', angularUniversal({
index: 'path/to/index.html',
main: 'path/to/main.<some-long-hash>.bundle',
enableProdMode: true
app.listen(3005, () => { console.log('Listening on 3005'); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment