Pdf viewer TI working on developer not working on server

Forum to discuss the new web client version of Servoy.

Pdf viewer TI working on developer not working on server

Postby Juan Etec » Fri Dec 13, 2024 11:32 am

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?
Un Saludo

Juan Ramírez
Juan Etec
 
Posts: 73
Joined: Mon Apr 20, 2009 8:23 pm
Location: Gran Canaria - Spain

Re: Pdf viewer TI working on developer not working on server

Postby vik.lamp.vl » Fri Dec 13, 2024 12:19 pm

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:

Code: Select all
    <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.

cache_problem.png


Hope it helps

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

Code: Select all
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
You do not have the required permissions to view the files attached to this post.
Servoy Developer
Head of Development at HV-Office & Hogatec.IT

Always interested in deeper Servoy-Knowledge so lets link up!
vik.lamp.vl
 
Posts: 48
Joined: Wed May 26, 2021 3:37 pm
Location: Germany

Re: Pdf viewer TI working on developer not working on server

Postby Juan Etec » Fri Dec 13, 2024 2:09 pm

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

Thanks for your reply.
Un Saludo

Juan Ramírez
Juan Etec
 
Posts: 73
Joined: Mon Apr 20, 2009 8:23 pm
Location: Gran Canaria - Spain

Re: Pdf viewer TI working on developer not working on server

Postby jcompagner » Tue Dec 17, 2024 11:55 am

newer tomcat already have this mime type setup by default.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8884
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Pdf viewer TI working on developer not working on server

Postby vik.lamp.vl » Tue Dec 17, 2024 12:09 pm

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.
Servoy Developer
Head of Development at HV-Office & Hogatec.IT

Always interested in deeper Servoy-Knowledge so lets link up!
vik.lamp.vl
 
Posts: 48
Joined: Wed May 26, 2021 3:37 pm
Location: Germany


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 1 guest