I'm setting up a server with express that I want to serve a rest API and two Angular5 applications.
I have a nginx proxy in front of me that redirects the traffic to the express application, transforming http requests to https.
The directory structure is:
servidor.js (Apliacion express)
├── api
├── app1
│ ├──index.html
│ ├──assets
│ └──*.js y *.css
└── app2
├──index.html
├──assets
└──*.js y *.css
On the express server I have:
require('./api/index')(app);
const options = { extensions: ['html', 'js', 'css'],
maxAge: '1d',
setHeaders: res => res.set('x-timestamp', Date.now() )}
app.use('/app1', express.static(path.join(__dirname, '/app1'), options));
app.use('/app2', express.static(path.join(__dirname, '/app2'), options));
app.get('/app1', (req, res) => {
res.type('html');
res.sendFile(__dirname + '/app1/index.html');
});
app.get('/app2', (req, res) => {
res.type('html');
res.sendFile(__dirname + '/app2/index.html');
});
The API answers me correctly.
/ answers me with app1.
/ app1 responds with app1.
I have the problem with app2 since / app2 responds with the correct html of app2 but with the following errors in loading the js and the css:
Refused to apply style from 'https://midominio.com/styles.9c0ad73….bundle.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
midominio.com/:1 GET https://midominio.com/inline.8f40296….bundle.js net::ERR_ABORTED
midominio.com/:1 GET https://midominio.com/polyfills.f20484b….bundle.js net::ERR_ABORTED
midominio.com/:1 GET https://midominio.com/main.56d2be6….bundle.js net::ERR_ABORTED
And even better, I would need to collect parameters from the url to directly access internal routes of the application.
For example: link
Can someone help me with this?
Greetings.