Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't work if nextcloud is installed on subfolder #51

Open
Thatoo opened this issue Nov 4, 2024 · 3 comments
Open

doesn't work if nextcloud is installed on subfolder #51

Thatoo opened this issue Nov 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Thatoo
Copy link
Contributor

Thatoo commented Nov 4, 2024

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Install nextcloud in a subdirectory https://domain.tld/nextcloud
  2. go to https://domain.tld/nextcloud/index.php/apps/picker/single-link
  3. Get the following error in console :
Uncaught (in promise) ChunkLoadError: Loading chunk node_modules_nextcloud_dialogs_dist_chunks_index-CYiQsZoY_mjs failed.
(error: https://domain.tld/apps/picker/js/picker-node_modules_nextcloud_dialogs_dist_chunks_index-CYiQsZoY_mjs.js?v=c2373e41314815cfcd22)

It obviously can't work as the link doesn't include the subfolder, it should be instead https://domain.tld/nextcloud/apps/picker/js/picker-node_modules_nextcloud_dialogs_dist_chunks_index-CYiQsZoY_mjs.js?v=c2373e41314815cfcd22

Expected behaviour

picker should load

Actual behaviour

picker can't load because the subfolder isn't taken in account in the chunk url

Image

Server configuration

Web server: ache/Nginx

Database: MySQL/Maria/

PHP version: 8.3

Nextcloud version: 29.0.7

List of activated apps
Enabled:
  - activity: 2.21.1
  - circles: 29.0.0-dev
  - cloud_federation_api: 1.12.0
  - comments: 1.19.0
  - contactsinteraction: 1.10.0
  - dashboard: 7.9.0
  - dav: 1.30.1
  - federatedfilesharing: 1.19.0
  - federation: 1.19.0
  - files: 2.1.1
  - files_downloadlimit: 2.0.0
  - files_external: 1.21.0
  - files_pdfviewer: 2.10.0
  - files_reminders: 1.2.0
  - files_sharing: 1.21.0
  - files_trashbin: 1.19.0
  - files_versions: 1.22.0
  - firstrunwizard: 2.18.0
  - logreader: 2.14.0
  - lookup_server_connector: 1.17.0
  - nextcloud_announcements: 1.18.0
  - notifications: 2.17.0
  - oauth2: 1.17.1
  - password_policy: 1.19.0
  - photos: 2.5.0
  - picker: 1.0.11
  - privacy: 1.13.0
  - provisioning_api: 1.19.0
  - recommendations: 2.1.0
  - related_resources: 1.4.0
  - riotchat: 0.18.3
  - serverinfo: 1.19.0
  - settings: 1.12.0
  - sharebymail: 1.19.0
  - support: 1.12.0
  - survey_client: 1.17.0
  - systemtags: 1.19.0
  - text: 3.10.1
  - theming: 2.4.0
  - twofactor_backupcodes: 1.18.0
  - user_ldap: 1.20.0
  - user_status: 1.9.0
  - viewer: 2.3.0
  - weather_status: 1.9.0
  - workflowengine: 2.11.0
Disabled:
  - admin_audit: 1.19.0
  - bruteforcesettings: 2.9.0
  - encryption: 2.17.0
  - riotchat_bak: 0.18.3
  - suspicious_login: 7.0.0
  - twofactor_totp: 11.0.0-dev
  - updatenotification: 1.19.1 (installed 1.19.1)
Nextcloud configuration
{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "zyuno.local"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "29.0.7.1",
        "overwrite.cli.url": "https:\/\/zyuno.local\/nextcloud",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "updatechecker": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "integrity.check.disabled": true,
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "6379",
            "timeout": "0.0",
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "hashing_default_password": true,
        "localstorage.allowsymlinks": true,
        "simpleSignUpLink.shown": false,
        "maintenance_window_start": 1,
        "mail_smtpmode": "smtp",
        "mail_smtpport": "25",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpstreamoptions": {
            "ssl": {
                "allow_self_signed": true,
                "verify_peer": false,
                "verify_peer_name": false
            }
        },
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "logout_url": "https:\/\/zyuno.local\/yunohost\/sso\/?action=logout&r=aHR0cHM6Ly96eXVuby5sb2NhbC9uZXh0Y2xvdWQ="
    }
}

Browser

Browser name: Firefox
Browser version: 132

Operating system: Linux NixOS

Browser log
Uncaught (in promise) ChunkLoadError: Loading chunk node_modules_nextcloud_dialogs_dist_chunks_index-CYiQsZoY_mjs failed.
(error: https://zyuno.local/apps/picker/js/picker-node_modules_nextcloud_dialogs_dist_chunks_index-CYiQsZoY_mjs.js?v=c2373e41314815cfcd22)
    j jsonp chunk loading:27
    e ensure chunk:6
    e ensure chunk:5
    pick index.mjs:69
    <anonymous> main.js:128
    EventListener.handleEvent* main.js:163
    <anonymous> main.js:173
    <anonymous> main.js:173
[jsonp chunk loading:27:17](webpack:///picker/webpack/runtime/jsonp%20chunk%20loading)
    pick index.mjs:69
    AsyncFunctionThrow self-hosted:804
    (Asynchrone : async)
    <anonyme> main.js:128
    (Asynchrone : EventListener.handleEvent)
    <anonyme> main.js:163
    <anonyme> main.js:173
    <anonyme> main.js:173
@Thatoo Thatoo added the bug Something isn't working label Nov 4, 2024
@Thatoo Thatoo changed the title subfolder doesn't work if nextcloud is installed on subfolder Nov 4, 2024
@provokateurin
Copy link
Member

There is nothing special this app is doing, do you have your server configured correctly such that it knows it sits in a subfolder?

@Thatoo
Copy link
Contributor Author

Thatoo commented Nov 5, 2024

Yeah, I was surprised to face this issue because when I worked on it previously I didn't notice it.

do you have your server configured correctly such that it knows it sits in a subfolder

I think so, I provided the Nextcloud configuration above and here is the nginx conf :

# Add .mjs as a file extension for javascript
# Either include it in the default mime.types list
# or include you can include that list explicitly and add the file extension
# only for Nextcloud like below:
include mime.types;
types {
    text/javascript js mjs;
}

location ^~ /.well-known {
  # The following 6 rules are borrowed from `.htaccess`

  # The following 2 rules are only needed for the user_webfinger app.
  # Uncomment it if you're planning to use this app.
  #rewrite ^/\.well-known/host-meta\.json  /nextcloud/public.php?service=host-meta-json  last;
  #rewrite ^/\.well-known/host-meta        /nextcloud/public.php?service=host-meta       last;

  location = /.well-known/carddav     { return 301 /nextcloud/remote.php/dav/; }
  location = /.well-known/caldav      { return 301 /nextcloud/remote.php/dav/; }

  location = /.well-known/webfinger     { return 301 /nextcloud/index.php$request_uri; }
  location = /.well-known/nodeinfo      { return 301 /nextcloud/index.php$request_uri; }

  # Let Nextcloud's API for `/.well-known` URIs handle all other
  # requests by passing them to the front-end controller.
  return 301 /nextcloud/index.php$request_uri;
}

 rewrite ^/nextcloud$ /nextcloud/ permanent;
location ^~ /nextcloud/ {

  # Path to source
  alias /var/www/nextcloud/;

  # set max upload size and increase upload timeout:
  client_max_body_size 10G;
  client_body_timeout 300s;
  fastcgi_buffers 64 4K;

  # Enable gzip but do not remove ETag headers
  gzip on;
  gzip_vary on;
  gzip_comp_level 4;
  gzip_min_length 256;
  gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

  # Pagespeed is not supported by Nextcloud, so if your server is built
  # with the `ngx_pagespeed` module, uncomment this line to disable it.
  #pagespeed off;

  # The settings allows you to optimize the HTTP2 bandwitdth.
  # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
  # for tunning hints
  client_body_buffer_size 512k;

  # HTTP response headers borrowed from Nextcloud `.htaccess`
  #more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
  more_set_headers "Referrer-Policy: no-referrer";
  more_set_headers "X-Content-Type-Options: nosniff";
  more_set_headers "X-Download-Options: noopen";
  more_set_headers "X-Frame-Options: SAMEORIGIN";
  more_set_headers "X-Permitted-Cross-Domain-Policies: none";
  more_set_headers "X-Robots-Tag: noindex, nofollow";
  more_set_headers "X-XSS-Protection: 1; mode=block";

  # Remove X-Powered-By, which is an information leak
  fastcgi_hide_header X-Powered-By;

  # Specify how to handle directories -- specifying `/nextcloud/index.php$request_uri`
  # here as the fallback means that Nginx always exhibits the desired behaviour
  # when a client requests a path that corresponds to a directory that exists
  # on the server. In particular, if that directory contains an index.php file,
  # that file is correctly served; if it doesn't, then the request is passed to
  # the front-end controller. This consistent behaviour means that we don't need
  # to specify custom rules for certain paths (e.g. images and other assets,
  # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus
  # `try_files $uri $uri/ /nextcloud/index.php$request_uri`
  # always provides the desired behaviour.
  index index.php index.html /nextcloud/index.php$request_uri;

  # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
  location = /nextcloud/ {
      if ( $http_user_agent ~ ^DavClnt ) {
          return 302 /nextcloud/remote.php/webdav/$is_args$args;
      }
  }

  location = /nextcloud/robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # Rules borrowed from `.htaccess` to hide certain paths from clients
  location ~ ^/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)    { return 404; }
  location ~ ^/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console)                  { return 404; }

  # Ensure this block, which passes PHP files to the PHP process, is above the blocks
  # which handle static assets (as seen below). If this block is not declared first,
  # then Nginx will encounter an infinite rewriting loop when it prepends
  # `/nextcloud/index.php` to the URI, resulting in a HTTP 500 error response.
  location ~ \.php(?:$|/) {
    # Required for legacy support
    rewrite ^/nextcloud/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /nextcloud/index.php$request_uri;

    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    set $path_info $fastcgi_path_info;

    try_files $fastcgi_script_name =404;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param HTTPS on;

    fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
    fastcgi_param front_controller_active true;     # Enable pretty urls
    fastcgi_param HTTP_ACCEPT_ENCODING "";          # Disable encoding of Nextcloud response to inject ynh scripts
    fastcgi_pass unix:/var/run/php/php8.3-fpm-nextcloud.sock;

    fastcgi_intercept_errors on;
    fastcgi_request_buffering off;

    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_connect_timeout 600;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
  }

  location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
       try_files $uri/ =404;
       index index.php;
  }

  # Serve static files
  location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
    try_files $uri / /nextcloud/index.php$request_uri;
    expires 6M;         # Cache-Control policy borrowed from `.htaccess`
    access_log off;     # Optional: Don't log access to assets

    location ~ \.wasm$ {
            default_type application/wasm;
    }
  }

  location ~ \.woff2?$ {
    try_files $uri / /nextcloud/index.php$request_uri;
    expires 7d;         # Cache-Control policy borrowed from `.htaccess`
    access_log off;     # Optional: Don't log access to assets
  }

  # Rule borrowed from `.htaccess`
    location /nextcloud/remote {
      return 301 /nextcloud/remote.php$request_uri;
    }

  location ~ / {
    if ($request_method ~ ^(PUT|DELETE|PATCH|PROPFIND|PROPPATCH)$) {
        rewrite ^ /nextcloud/index.php$request_uri last;
    }
    try_files $uri / /nextcloud/index.php$request_uri;
    }
}

Let me know if you think something is wrong in either of the two.

@Thatoo
Copy link
Contributor Author

Thatoo commented Feb 9, 2025

This issue is still valid on latest version of nextcloud and picker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants