I'm surprised that there are so many questions regarding the same problem but there are no good answers anywhere. In fact this question doesn't even have a single answer. Anyway, my problem is much similar. Everything was working fine before I decided to run my frontend and backend both on same port (PORT 3000 in my case). I followed these steps:
- Used
ng build --prod
to compile development file. Adist
folder was created. - Then just uploaded all the server files and dist folder to server.
- And run the server using pm2. The command is
pm2 start server.js
.
Well I know from where did these lines come in index.html
:
script src="runtime-es2015.858f8dd898b75fe86926.js" type="module"
script src="polyfills-es2015.5728f680576ca47e99fe.js" type="module"
script src="runtime-es5.741402d1d47331ce975c.js" nomodule>
script src="polyfills-es5.7f43b971448d2fb49202.js" nomodule>
script src="main-es2015.ec7a803b995f0d691eeb.js" type="module">
script src="main-es5.1cd51b4ce24f28c1391b.js" nomodule>
But now they are creating these errors:
Loading module from “http://localhost:3000/runtime-es2015.858f8dd898b75fe86926.js” was blocked because of a disallowed MIME type (“text/html”).
Loading module from “http://localhost:3000/polyfills-es2015.5728f680576ca47e99fe.js” was blocked because of a disallowed MIME type (“text/html”).
Loading module from “http://localhost:3000/main-es2015.ec7a803b995f0d691eeb.js” was blocked because of a disallowed MIME type (“text/html”).
I tried setting type=text/javascript
and many more solutions and hacks. But nothing is working.
PS: Here is the entire project before build. View its README also.