I am using ngx-extended-pdf-viewer in my Angular app deployed on Azure app service (Linux).
angular.json config (as per docs)

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?
MIME-type issues with .mjs files on Azure App Service (Linux) are due to the Startup Command in Stack settings of Configuration.
It should have pointed to the dist folder, so changing it to
npm install -g @angular/clibashCopy code
ng new my-angular-appFollow the prompts to set up your project. You can choose options like routing and styling during this process
cd my-angular-appRun the following command to serve your Angular app locally:
bashCopy code
ng serveYour Angular app will be accessible at
http://localhost:4200/by default. Open this URL in your browser, and you should see the default Angular app.Local:
Deployment Status:
Deployment of the web app to Azure from Visual Studio Code has been completed.
Enter
pm2 serve /home/site/wwwroot/dist --no-daemon --spaunder Startup Command and click saveAzure:
With ngx-extended-pdf-viewer:
Below is the full code for an Angular project that uses
ngx-extended-pdf-viewerto display a PDFOpen the
angular.jsonfile and update theassetssection underprojectsapp.module.ts:
app.component.ts:
app.component.html:
Local:
Azure: