-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting 'MIME type' errors which prevent PDF display #17296
Comments
This error message says that your web-server isn't correctly configured, since it returns an incorrect MIME type for
For future reference: Please remember to provide a version number, since what "latest" is (obviously) changes over time. |
Ah, of course. We're using nginx, and that is configured in /etc/nginx/mime.types in our case. Thank you. |
hi, how you configured nginx to success deal it ? thx |
thx, we deal it. use ..... |
For the sake of better search results, the error I was getting in Safari was: TypeError: text/plain is not a valid JavaScript MIME type I use Apache, so I edited /etc/mime.types and added mjs after js on the same line as the existing text/javascript entry. I didn't need to restart Apache but did need to clear my browser cache. |
thx, i did the same and it works perfectly
|
If you use Apache, you can set it by updating the .htaccess file:
|
This nginx config works perfectly for me: server {
# ...
location / {
root /usr/share/nginx/html;
index index.html;
location ~* \.mjs$ {# target only *.mjs files
# now we can safely override types since we are only
# targeting a single file extension.
types {
text/javascript mjs;
}
}
}
} Thanks to the author! https://stackoverflow.com/a/19630564/12674896 |
@alekswebnet hi there, I used to your code but doesn't help, can you guide me: |
@shivangi-2001, sorry but this issue has been closed a while back and is unrelated to pdf.js itself (see #17296 (comment)). So please don't use this issue tracker as a chat room. Thank you. |
I am getting these MIME type errors which prevent my test file pageviewer.html from displaying the pdf:
For /node_modules/pdfjs-dist/build/pdf.mjs:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
For /node_modules/pdfjs-dist/web/pdf_viewer.mjs:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
For pageviewer.js:
Uncaught ReferenceError: pdfjsLib is not defined
How can I fix these? I'm also not sure how to reference what pdf file to display. I'm trying to use the pageviewer.html example from the examples folder here.
I have the latest npm and nodejs installed.
Any help is appreciated!
Configuration:
Steps to reproduce the problem:
What is the expected behavior? (add screenshot)
To display the pdf
What went wrong? (add screenshot)
Completely blank web page, with the above errors in the Developer Tools Console.
Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
https://subs.humortimes.com/pageviewer.html
The text was updated successfully, but these errors were encountered: