0

I have compiled my Angular FE and placed it in the nodejs BE public folder which is accessible from browser:

app.use(express.static('public'));

and set up express to serve the content:

app.use('', (req, res, next) => {
        res.sendFile(path.join(__dirname, '../public/clientApp', 'index.html'));
    });

But I'm getting this puzzling errors in the browser console:

Loading module from “http://localhost:3000/runtime-es2015.e3e9ca9bbd4db2ff1ff0.js” was blocked because of a disallowed MIME type (“text/html”).
Loading module from “http://localhost:3000/polyfills-es2015.6db406a075ad3aed7ba9.js” was blocked because of a disallowed MIME type (“text/html”).
Loading module from “http://localhost:3000/main-es2015.2b6d7bc5e864e8a8e238.js” was blocked because of a disallowed MIME type (“text/html”).

Not sure what's going on...

youri
  • 1,140
  • 8
  • 19

1 Answers1

0

ok, here's what it was. as often console errors didn't help a bit. so, just marking top level directory

app.use(express.static('public'));

as static wasn't enough when loading external js and css. I also had to mark subdirectory where the compiled js and css files are as static (although it's static already)

app.use(express.static('public/clientApp'));