Pdf viewer TI working on developer not working on server

Hi,
using PDF viewer in TI (Servoy version 2024.3.4) it works fine in developer, but in server not.
Looking at browser inspector it shows that error:

pdf.mjs:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “”. Strict MIME type checking is enforced for module scripts per HTML spec.
viewer.mjs:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “”. Strict MIME type checking is enforced for module scripts per HTML spec.

Is this a server configuration problem?
How can I solve it?

Hi Juan,

i had exactly the same problem with a customer last month.
The normal PDF Viewer would load the PDFs but PDFjs was not loading anything. I had the same Error-msg in the dev-console.
It seemed that something blocked .mjs files which PDFjs uses.

Servoy: 2024.9.1.4003
Tomcat 9
Servoy PDF Viewer: 2024.3.1

I fixed it like this:

In my Tomcat web.xml i added a mime-mapping block:

    <mime-mapping>
        <extension>mjs</extension>
        <mime-type>application/javascript</mime-type>
    </mime-mapping>

Restarted the Tomcat and it worked.

For some users it was still broken (they had a older chrome and firefox installed)
For this i opened the Developer-Console in the browser and under “Network” i enabled “deactivate Cache” → reloaded the page and it worked.
After that you can disable “deactivate cache” again.

[attachment=0]cache_problem.png[/attachment]

Hope it helps

P.S
oh and im loading the pdf via elements.pdfjs.documentURL = PDF_URL and not via dataprovider

var remoteJSFile = plugins.file.convertToRemoteJSFile(scopes.files.USER_TEMP_PATH_URL + 'invoice_' + _invoice_nr + '.pdf')
var remoteURL	 = plugins.file.getUrlForRemoteFile(remoteJSFile)
elements.pdfjs.documentURL = remoteURL

-Vik

Ok Viktor, I will try.
I need to restart my tomcat to verify it.

Thanks for your reply.

newer tomcat already have this mime type setup by default.

Hi Johan,

just checked some things out.
Where using Tomcat 9.0.71 and added the mimetype ourself.

I looked at the tomcat changelog, it seems they added it in the version 9.0.85.

Just for future questions on this topic.