I have created a Cordova application which simply serves the default Angular welcome page when creating a a new project. It works fine in the browser. It works fine when run it on an emulator via Android Studio.
When I run it on my android device I get a blank page and the following error is available in the console:
polyfills-es2015.5728f680576ca47e99fe.js:1 Failed to load module script: The
server responded with a non-JavaScript MIME type of "". Strict MIME type
checking is enforced for module scripts per
HTML spec.
main-es2015.734c1bff4ed0a6bbbd29.js:1 Failed to load module script: The
server responded with a non-JavaScript MIME type of "". Strict MIME type
checking is enforced for module scripts per HTML spec.
I can fix this by editing by dist/<project>/index.html created by Angular. Angular no longer includes the type="text/javascript" parameters in the <script> tags it creates. Instead they look like this:
<script src="runtime-es2015.858f8dd898b75fe86926.js" type="module"></script>
<script src="polyfills-es2015.5728f680576ca47e99fe.js" type="module"></script>
<script src="runtime-es5.741402d1d47331ce975c.js" nomodule></script>
<script src="polyfills-es5.7f43b971448d2fb49202.js" nomodule></script>
<script src="main-es2015.734c1bff4ed0a6bbbd29.js" type="module"></script>
<script src="main-es5.43ecaae92d6e77bfb1c5.js" nomodule></script>
If I change that to type="text/javascript" the app runs correctly on my device.
How can I tell Cordova to include the correct MIME type headers when serving the javascript files?