I'm hosting my angular 6 app with express static
app.use(express.static('/', __dirname +'/client/angular'));
The problem came when i tried to add another page to my server as a landing page. So i specified a mounth path '/app' to my angular app.
app.use(express.static('/app', __dirname +'/client/angular'));
This is not working! When i run the server this came out
GET /app/ 304 4.294 ms - -
GET /inline.bundle.js/ 404 1.065 ms - 15
GET /polyfills.bundle.js/ 404 0.581 ms - 15
GET /styles.bundle.js/ 404 2.195 ms - 15
GET /vendor.bundle.js/ 404 2.119 ms - 15
GET /main.bundle.js/ 404 1.830 ms - 15
GET /favicon.ico 404 0.474 ms - 15
I managed the problem hosting the new webpage in a virtual path '/home' and keep my angular app hosted in the root path by default.
app.use('/home', express.static(__dirname +'/client/landing'));
app.use('/', express.static(__dirname +'/client/angular'));
But these are not the routes i need so, does anybody know how to mount an angular app on express virtual path?
After digging a little bit more, i found out that I have to modify the index.html file of my angular app in the dist folder generated after run ng build. The problem was that the base href was "/", so when it needed the js files it didn't find them. So, all we have to do is change it, with the same path as it was mounted in the server
<base href="/app">