SOLVED: Blank inner view Drupal 10 with subdirectory as root install

Created on 10 January 2024, 11 months ago
Updated 27 January 2024, 10 months ago

Problem/Motivation

Issue: My Drupal 10 install is in a subdirectory off of the root webserver. I am able to see the viewer.html on the basic/article pages but they do not render a pdf file. The source URL shows a file=encoded location, which includes my file's location, so that part looks correct. When viewing the sources tab on the developer tools, the pdf/view.html returns a "source not found" for both the build/pdf.mjs and the web/viewer.mjs, but when I look at the PdfThumbnail.pdf/pages.pdf/default.pdf files and check the worker source, the pathing looks correct. I am aware that the pdf/viewer.html file has those two paths as hardcoded. The hardcoded values appear to be in the correct location for directory access if the worker file is processed correctly. I am also running on https. I updated my code with a patch found to check for HTTPS, but I don't believe that is affecting this issue since it was in place before I did anything in regard to the HTTPS.

Steps to reproduce

Install and chase down a bunch of different issue logs to find out how to add the PDF viewer to the Drupal site because there is no documentation about how to do it. Test by adding a PDF as a page. Watch it not work.

Additional troubleshooting
With more research and troubleshooting today via pdf.js debug tools, it appears to be an x-content-type-options nosniff catch due to the view.html wrapper being a text/HTML source, whereas the content is application/pdf.

I've tried updating my Content Security Policy tools and added the ForceType application/octet-stream to my .htaccess, but I have not yet found the magic combo to fix the problem. I will update the ticket as I continue to work on the problem, and if I find a solution that works for me, I will update the Proposed Resolution section with what I find.

Proposed resolution

For the blank page, download the prebuilt solution from the Mozilla project and install ALL OF IT UNALTERED into the libraries directory. This should fix all the blank page issues. As for the the "how do I use this thing"? I created a installation document. Please see the Zip of the PDF I created.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pftech

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024