Skip to content

Instantly share code, notes, and snippets.

@artyomsveshnikov
Created August 22, 2021 09:22
Show Gist options
  • Save artyomsveshnikov/e4e0d6346ed7e3695cc7ca5bdeac45cc to your computer and use it in GitHub Desktop.
Save artyomsveshnikov/e4e0d6346ed7e3695cc7ca5bdeac45cc to your computer and use it in GitHub Desktop.
Simple server.js for Angular static site
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist/<appName>'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/dist/<appName>/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