Opening a public shared link show a file not found message

Nextcloud version : 24.0.0 (but present in previous version)

The issue you are facing:
While I try to open a file shared by a public link, a message “File not found. The document wasn’t found on the server. Maybe the sharing was deleted or is expired” is shown.
*I’ve seen this issue but in my case all users are facing the problem.

Is this the first time you’ve seen this error? : No but I run an other nextcloud at the same web host and I don’t have the same problem. Plus, I seem to remember that at the initiation of this nextcloud, this sharing function was correct.

Steps to replicate it:

  1. On a file, create a shared doc thru public link
  2. Open the link on an other navigator or device
  3. See the message

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocshu0apq6jp',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'mysub.domain.org',
  ),
  'trusted_proxies' => 
  array (
    0 => '10.0.20.16',
  ),
  'forwarded_for_headers' => 
  array (
    0 => 'HTTP_X_FORWARDED_FOR',
  ),
  'datadirectory' => '/var/www/vhosts/mysub.domain.org/httpdocs/data',
  'tempdirectory' => '/var/www/vhosts/mysub.domain.org/var/tmp',
  'dbtype' => 'mysql',
  'version' => '24.0.0.12',
  'overwrite.cli.url' => 'https://mysub.domain.org',
  'dbname' => 'xxx',
  'dbhost' => 'my.host',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'mail_from_address' => 'support',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'domain.org',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.host',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'app_install_overwrite' => 
  array (
    0 => 'files_external_gdrive',
    1 => 'occweb',
    2 => 'jitsi',
    3 => 'richdocuments',
    4 => 'mindmap_app',
  ),
  'maintenance' => false,
  'loglevel' => 2,
  'default_phone_region' => 'FR',
  'default_language' => 'fr',
  'default_locale' => 'fr_FR',
  'auth.webauthn.enabled' => false,
);

Now ok !
The problem came from the “File Access Control” app which has an obsolete control which was too much restrictive.