I am learning to build a simple mean stack application. I have default angular project which runs fine. I want to run the angular app through express server but it showing error "Cannot GET /" in the browser.
Here is my code:
const express = require("express");
const compression = require("compression");
const _port = 4100;
const _app_folder = 'src/dist/app';
const app = express();
app.use(compression());
// ---- SERVE STATIC FILES ---- //
app.get('*.*', express.static(_app_folder, {maxAge: '1y'}));
// ---- SERVE APLICATION PATHS ---- //
app.all('*', function (req, res) {
res.status(200).sendFile('/', {root: _app_folder});
});
// ---- START UP THE NODE SERVER ----
app.listen(_port, function () {
console.log("Node Express server for " + app.name + " listening on http://localhost:" + _port);
});