Search code examples
angularazure-web-app-servicengx-extended-pdf-viewer

Mime type of .mjs file from Azure App service is 'text/plain' (only in Production server)


I am using ngx-extended-pdf-viewer in my Angular app deployed on Azure app service (Linux).

angular.json config (as per docs) enter image description here

The .mjs files are included in assets/ folder and works fine in development mode. However, when deployed on production server, it gives the following error:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

I tried configuring the mime types on Azure but since it does not use a reverse proxy such as ngnix, I am unable to configure mjs to be returned as application/javascript. Since its Linux, web.config doesnt work either.

Is there a way from Azure Portal to configure this?


Solution

  • I do not use azure but i had the same error. The problem is, that in my mime.types file there was no content-type mapping to .mjs files. After adding this (application/javascript) it worked just fine! I hope it helps