nextcloud / files_pdfviewer

:book: A PDF viewer for Nextcloud
GNU Affero General Public License v3.0
88 stars 44 forks source link

PDF viewer not working with shared links #1063

Open Winterkeks opened 3 weeks ago

Winterkeks commented 3 weeks ago

How to use GitHub


Steps to reproduce

  1. Update on Nextcloud version 30
  2. Open a PDF with the Viewer

Expected behaviour

Tell us what should happen Normaly it you should see the PDF

Actual behaviour

Tell us what happens instead, if possible also add a screenshot When I open the PDF a black screen appears

Server configuration

Database: MySQL/Maria/SQLite/PostgreSQL MariaDB

Nextcloud version: (see Nextcloud admin page) 30.0.0

List of activated apps Auditing / Logging Brute-force settings External storage support File sharing Files download limit Nextcloud webhook support Password policy Share by mail PDF Viewer 3.0.0 ``` If you have access to your command line run e.g.: sudo -u www-data php occ app:list from within your Nextcloud installation folder ```
Nextcloud configuration ``` If you have access to your command line run e.g.: sudo -u www-data php occ config:list system from within your Nextcloud installation folder ```

Browser

Browser name: Firefox/Chrome/Safari/… In every Browser it doesnt work Browser version: 124/125/…

Operating system: Windows/Ubuntu/Mac/… Windows

Browser log ``` Insert your browser log here, this could for example include: a) The javascript console log b) The network log ``` Browser Console ![image](https://github.com/user-attachments/assets/d312d6dd-4b5a-4d82-beca-bb75b7ab9ed2)

If I open a PDF normally and i am logged in as a user on the nextcloud, the PDF opens and I see it. But if I share a PDF and open the link in another browser and I'm not logged in there, all I see is a blank screen.

I use docker and there the Nextcloud container: https://hub.docker.com/layers/library/nextcloud/30.0.0/images/sha256-0f19a49f4169d4622128f73b8b84110dccd8d7b6c925e1cc54860914be549e89?context=explore

Not working: nextcloud1

Working (If iam logged in): nextcloud2

madrzejewski commented 2 weeks ago

Hi,

I can confirm that I have the same bug on my side. The preview don't work on shared links, but it works when authenticated.

I think the problem is that it returns an HTTP 401 when the preview script tries to fetch the PDF.

I noticed a 401 error on this kind of links :

https://redacted-server.com/public.php/dav/files/3mQSWszDagxCo7p/

Edit : I'm also on Nextcloud V30

Edit 2 : However, the download of the file works fine, no 401 on this.

alpsayin commented 1 week ago

Also affected.

If I disable both PDF Viewer and Built-in Collabora Server (but not remove them), then at least somehow Nextcloud Office still finds the Builtin Collabora in apps, and generates a preview. It's ugly but it's something.

I think this is also related and it's where I got the idea from; https://help.nextcloud.com/t/pdf-files-wont-open/188277/9

joshtrichards commented 1 week ago

Possibly related: #946

madrzejewski commented 1 week ago

I think I have the same issues on MP3 files. The mp3 player does not show up and I have the same 401 errors (but I can still download the file).

So it may be a broader issue with the previewing of all public/shared files.

EDIT: Similar error with mp4 file. But images & .md files previews are working.

boutilpj commented 1 week ago

I tracked down where the 401 is coming from.

apps/dav/appinfo/v2/publicremote.php , starting at line 78.

if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { // this is what is thrown when trying to access a non-existing share throw new NotAuthenticated(); }

I tested by comment out the throw line and I was able to view the PDF as expected.

Noticing isOutgoingServer2serverShareEnabled , I took a look in Administration settings -> Sharing -> Federate Cloud Sharing and noticed this setting which was off. Turning it on (with the throw back in the above code) also fixes the issue.

Allow people on this server to send shares to other servers (this option also allows WebDAV access to public shares) .

madrzejewski commented 1 week ago

Thanks @boutilpj, from what I managed to find, it seems to be fixed in a recent commit bbc5d32c8e14de78ae12c3acea384c69d2264eca in this pull request 48628

asayin-xlnx commented 1 week ago

Thanks @madrzejewski and indeed Nextcloud update to 30.0.1 fixed it.