TwisterMc / pdfjs-viewer-shortcode

A Wordpress plugin for embedding PDFs using Mozilla's Excellent PDF.js
https://wordpress.org/plugins/pdfjs-viewer-shortcode/
Apache License 2.0
7 stars 5 forks source link

File origin does not match the viewer's #6

Open JulianElwood opened 3 years ago

JulianElwood commented 3 years ago

I get this error with any pdf I try to display. I have media settings option to store media by year and date switched on - Is this causing the error with loading the pdf? Only threads I see on the web seem to imply I either need to:

Set HOSTED_VIEWER_ORIGINS_OPTIONS - I don't know where to set this or what format is needed

Comment out code for this message - I feel this is unsafe and I don't want to change plug in code in any way

Please help resolve this for me

TwisterMc commented 3 years ago

Do you have a URL I could look at?

Are you using a VPN? If so, that might be causing the issue.

JulianElwood commented 3 years ago

My site is not live yet as we are still in final stages of setting it up. If you want me to put it live for a few minutes (while we are on a call together) so you see the issue then please let me know the time that suits you and what number I should call you on. I am not using a VPN as these are illegal in China (as we are setting up a China company that will depend on Ministry approval for our on line activities I want to ensure full compliance with all local laws.) Julian

From: Thomas McMahon notifications@github.com Sent: 04 August 2020 09:46 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

Do you have a URL I could look at?

Are you using a VPN? If so, that might be causing the issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-668329616&data=02%7C01%7C%7C1d73c16c68694f72b8e508d838181ce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321023496625100&sdata=h1393r68OlnZYhvgMDPrkAzNQoEQ3AB%2Fl8JZiVPwci8%3D&reserved=0, or unsubscribehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTAFZ7BJ2IXGBOMIZV3R65R4XANCNFSM4PT365JQ&data=02%7C01%7C%7C1d73c16c68694f72b8e508d838181ce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321023496635098&sdata=w4riPu32jJ8W1Et8NIgyfxeUr6uRMjmAeI1nPhiuN4g%3D&reserved=0.

JulianElwood commented 3 years ago

I see the following code against the block for a pdf viewer:

[pdfjs-viewer viewer_width=0 viewer_height=300 url=https://safetystock.guru/wp-content/uploads/2020/08/YBL_Inventory_Optimization_Performance_Product_Brief_1.0_EN.pdf download=true print=true fullscreen=true fullscreen_text="View%20Fullscreen" zoom=auto ]

Hope this helps, Regards

Julian

From: Thomas McMahon notifications@github.com Sent: 04 August 2020 09:46 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

Do you have a URL I could look at?

Are you using a VPN? If so, that might be causing the issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-668329616&data=02%7C01%7C%7C1d73c16c68694f72b8e508d838181ce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321023496625100&sdata=h1393r68OlnZYhvgMDPrkAzNQoEQ3AB%2Fl8JZiVPwci8%3D&reserved=0, or unsubscribehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTAFZ7BJ2IXGBOMIZV3R65R4XANCNFSM4PT365JQ&data=02%7C01%7C%7C1d73c16c68694f72b8e508d838181ce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321023496635098&sdata=w4riPu32jJ8W1Et8NIgyfxeUr6uRMjmAeI1nPhiuN4g%3D&reserved=0.

TwisterMc commented 3 years ago

Sorry. I didn't mean VPN, I meant CDN. 🤦‍♂️

The PDF has to load from the same URL as the the site is loading from. If the PDF is offloaded to a CDN, then the URLs won't match.

JulianElwood commented 3 years ago

Hi I must be doing something wrong that should hopefully be easy to fix!! The pdf is in my media library on the same site as the web pages which malfunction. Regards

Julian

From: Thomas McMahon notifications@github.com Sent: 04 August 2020 11:37 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

Sorry. I didn't mean VPN, I meant CDN. 🤦‍♂️

The PDF has to load from the same URL as the the site is loading from. If the PDF is offloaded to a CDN, then the URLs won't match.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-668361105&data=02%7C01%7C%7Ca1932ef751be402d11be08d83827a70d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321090234710720&sdata=27SJicVXMHCZGNPhsNwphVoqc2D8fwvZFtJyF5eKKZo%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTD4OXLK346H2FTO37DR65655ANCNFSM4PT365JQ&data=02%7C01%7C%7Ca1932ef751be402d11be08d83827a70d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321090234720717&sdata=xDqFgv68GtIASLdkONJAp2orZrWbENaDUYPJBgAjmqA%3D&reserved=0.

TwisterMc commented 3 years ago

If you add a PDF to a page, and have the 'Fullscreen' link enabled, can you view the post, hit the 'Fullscreen' link and then paste that link here? It doesn't need to be accessible to me, but I want to see what it looks like.

Example: https://olaf.local/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=https%3A%2F%2Folaf.local%2Fwp-content%2Fuploads%2F2020%2F03%2F7700.pdf&dButton=true&pButton=true&oButton=false&v=1.5.1#zoom=auto

JulianElwood commented 3 years ago

Hi, Sorry for delayed reply – I have checked this and the link appears to have the right address in the media library as in attachment. Hope this helps as I would really like to get your plug in working – it seems to have the best functionality for what I need to do! Regards Julian

From: Thomas McMahon notifications@github.com Sent: 05 August 2020 10:06 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

If you add a PDF to a page, and have the 'Fullscreen' link enabled, can you view the post, hit the 'Fullscreen' link and then paste that link here? It doesn't need to be accessible to me, but I want to see what it looks like.

Example: https://olaf.local/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=https%3A%2F%2Folaf.local%2Fwp-content%2Fuploads%2F2020%2F03%2F7700.pdf&dButton=true&pButton=true&oButton=false&v=1.5.1#zoom=auto

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-668931569&data=02%7C01%7C%7C6752d2748ece4de7b50e08d838e425ac%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321899811554556&sdata=sTQzN7Ip6RRCrOM41SbOxkG2k4CuhivQHTqAUJmmNVU%3D&reserved=0, or unsubscribehttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTGT4VTSVCDBH6GOFG3R7C5BZANCNFSM4PT365JQ&data=02%7C01%7C%7C6752d2748ece4de7b50e08d838e425ac%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321899811564554&sdata=vyO4an577%2BUUQzthRpuJLiFdwRKeeiilRgqVcAwfeq8%3D&reserved=0.

JulianElwood commented 3 years ago

Hi, I also have a Chinese site and was testing pdf plugs for that. I could not get PDFjs Viewer with the wordpress version on the Aliyun server and tried another plug in which worked ok (but did not work when I tried it on my international site hosted by Godaddy). Could be there is some strange error using your plug in that is to do with my location (but I’m not sure as people in UK have tested my site and also get the error!) Regards,

Julian

From: Thomas McMahon notifications@github.com Sent: 05 August 2020 10:06 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

If you add a PDF to a page, and have the 'Fullscreen' link enabled, can you view the post, hit the 'Fullscreen' link and then paste that link here? It doesn't need to be accessible to me, but I want to see what it looks like.

Example: https://olaf.local/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=https%3A%2F%2Folaf.local%2Fwp-content%2Fuploads%2F2020%2F03%2F7700.pdf&dButton=true&pButton=true&oButton=false&v=1.5.1#zoom=auto

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-668931569&data=02%7C01%7C%7C6752d2748ece4de7b50e08d838e425ac%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321899811554556&sdata=sTQzN7Ip6RRCrOM41SbOxkG2k4CuhivQHTqAUJmmNVU%3D&reserved=0, or unsubscribehttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTGT4VTSVCDBH6GOFG3R7C5BZANCNFSM4PT365JQ&data=02%7C01%7C%7C6752d2748ece4de7b50e08d838e425ac%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637321899811564554&sdata=vyO4an577%2BUUQzthRpuJLiFdwRKeeiilRgqVcAwfeq8%3D&reserved=0.

TwisterMc commented 3 years ago

Can either of you provide me the link the Fullscreen link is going to?

JulianElwood commented 3 years ago

Hi,

The full screen link was in a word doc attached to a previous email… it is

Link in media library… https://safetystock.guru/wp-content/uploads/2020/08/YBL_MRP_Training_Tool_Product_Brief_1.0_EN.pdf Click on View Fullscreen reveals same path… https://bmv.6ec.myftpupload.com/wp-content/plugins/pdfjs-viewer-shortcode/pdfjs/web/viewer.php?file=https://safetystock.guru/wp-content/uploads/2020/08/YBL_MRP_Training_Tool_Product_Brief_1.0_EN.pdf&dButton=true&pButton=true&oButton=false&v=1.5.1#zoom=auto

I have put my site live now and cannot test changes for a few days until I have a test site up and running. Still keen to see if this plug in can work for me as my workaround is not very good.

Regards

Julian

From: Thomas McMahon notifications@github.com Sent: 13 August 2020 21:12 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

Can either of you provide me the link the Fullscreen link is going to?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-673469767&data=02%7C01%7C%7C675cfcfce86944ef414d08d83f8a8048%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637329211368146705&sdata=5njaAmb7BBoxFp1V6KLMmgOTeBt%2Ba7wZmhxPU4fTEgY%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTDIKYQSHNURCRZDOFLSAPRC7ANCNFSM4PT365JQ&data=02%7C01%7C%7C675cfcfce86944ef414d08d83f8a8048%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637329211368157785&sdata=sqverTYav8ci0qVFSSoC5has3yK50bXAxYw8thHI%2BQU%3D&reserved=0.

TwisterMc commented 3 years ago

The issue is you can't have two different domains. You can only load PDFs from the same domain that the plugin is running on.

domain-issue
JulianElwood commented 3 years ago

Sorry to disagree but the plug in and the pdf are on the same domain! From my point of view the best way forward is to use a different plug in so I will not need a resolution to this, Regards Julian

From: Thomas McMahon notifications@github.com Sent: 17 August 2020 10:04 To: TwisterMc/pdfjs-viewer-shortcode pdfjs-viewer-shortcode@noreply.github.com Cc: JulianElwood julianlelwood@outlook.com; Author author@noreply.github.com Subject: Re: [TwisterMc/pdfjs-viewer-shortcode] File origin does not match the viewer's (#6)

The issue is you can't have two different domains. You can only load PDFs from the same domain that the plugin is running on.

[domain-issue]https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F46997%2F90350856-f9482500-e003-11ea-8dcf-57fdd5d3101f.png&data=02%7C01%7C%7C59f26cfb6ba14dba522e08d84251dab4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637332266604990891&sdata=jWgESCusqNxwaE8beAOKFB2UnoQehTvSKz%2Ffysc80Cw%3D&reserved=0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FTwisterMc%2Fpdfjs-viewer-shortcode%2Fissues%2F6%23issuecomment-674618427&data=02%7C01%7C%7C59f26cfb6ba14dba522e08d84251dab4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637332266604990891&sdata=ixRzOsiDBzqIEZZatTkrPdy%2FBqr%2F3gSPXVYqRo7F0Sg%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMZBHTESDDO466RATZDCH3DSBCF2HANCNFSM4PT365JQ&data=02%7C01%7C%7C59f26cfb6ba14dba522e08d84251dab4%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637332266605000881&sdata=hmZcPGvedFhFnVgOKQm5Vlb8EcXKgSk2G%2FNA4kpht5k%3D&reserved=0.

TwisterMc commented 3 years ago

As pointed out in the screenshot, it's reporting to different domains. It could be because it's on a staging site and the uploads are still pointing to production, or it could be that something is configured differently, but the plugin and media domain is different. They may technically be the same domain, but they have different addresses.

TwisterMc commented 3 years ago

Try the latest version and see if that helps any.

Catra-chordeon commented 3 years ago

Using Version: 1.5.7 (as in PlugIn library)/v2.3.200 on WordPress version 5.6 and having the same problem.
Black/blank pdf viewwer shows following error message: PDF.js v2.3.200 (build: 4ae3f9fc) Message: file origin does not match viewer's

the two pdf files I am trying to display or download are IN my media library, not linked to it. I'm using a more current version than JulianE above. BUT, i AM on a staging site. Thing is, the urls of the media library items have the staging site location incorporated into them. What do i do?

TwisterMc commented 3 years ago

Do you have a URL? This issue happens when the PDF is coming from a URL that is not the same as the URL that is showing the PDF.

rmykolas commented 3 years ago

Hi there @TwisterMc, I had the same issue, but I fixed it by adding a list of CDN links to var HOSTED_VIEWER_ORIGINS within the viewer.js file.

But for some reason, this hack does not work with the 1.5.9 version of the plugin. Would you mind updating the repo to see what's changed in the plugin and could be causing this?

Thanks!