PDF.JS can't find files (OJS 3.1.2-4)

Hi!
I upgraded from 2.4 to 3.1.2. Almost all functions work (thanks to reading this forum :slight_smile: ), apart from PDF.JS.

I can see PDFviewer window, but there is an error:

Missing PDF “https://…url…/plugins/generic/pdfJsViewer/pdf.js/web/228/439/”

The last two numbers refer to the file ID in database (not the filename).

What’s interesing, on the same page “Download” button works. It has link:

https://…url…/index.php/bpastudies/article/download/228/439/

Where should I look for the error? I think, pdf.js should get direct link to file, but maybe I’m wrong.

[EDIT]
I temporarily solved it changing line 18557 of pdf.js to:

var url = source.url.replace(‘plugins/generic/pdfJsViewer/pdf.js/web’,‘index.php/bpastudies/article/download’);

But I still don’t know where the source of the problem is. :frowning:

Hi @wawax,

Hmm, I’ve never seen that problem before. Are you using e.g. mod_rewrite, or a rewriting proxy, or something similar? Are there any other modifications to the code?

Regards,
Alec Smecher
Public Knowledge Project Team

I have strict Content-Security-Policy, which e.g. doesn’t allow adding URL within URL (returns 404 Forbidden). But I solved it removing https://…url…/ from template file and adding it later - in pdf.js.

Adding or removing .htaccess with mod_rewrite changes nothing. I had mod_rewrite in OJS2, but now it is obsolete.