I have one Node/Express server where I am serving both an Angular application and some static HTML. I serve the Angular application out of dist/angular and the static content out of static-content:
// This has to be in this order or else it doesnt work for some reason
app.use(express.static('./static-content'));
app.use(express.static('./dist/angular'));
app.use(parser.json());
// some other routes ...
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, '/static-content/index.html'));
});
app.get('/app/*', function (req, res) {
res.sendFile(path.join(__dirname, '/dist/angular/index.html'));
});
http.createServer(function (req, res) {
let httpsHost = req.headers.host.replace('8081', '8443');
res.writeHead(301, {"Location": "https://" + httpsHost + req.url});
res.end();
}).listen(8081);
https.createServer(httpsOptions, app).listen(8443)
If you change the order of the express.static at the top, it will not serve the static-content so I am wondering if this is the correct way to serve both an Angular application and HTML+CSS content out of one Node/Express server?