Skip to content

Built-in CODE Uses Wrong URL for fonts.json #312

Open

Description

@lzlrd

Running https://github.com/nextcloud/docker and noticed that the built-in CODE uses https://<Nextcloud Domain>/custom_apps/richdocuments/settings/fonts.json instead of https://<Nextcloud Domain>/apps/richdocuments/settings/fonts.json (as mentioned on https://<Nextcloud Domain>/settings/admin/richdocuments). This causes custom fonts not to be loaded.

richdocuments is indeed installed under /var/www/html/custom_apps so the problem isn't to do with it being under .../apps. I assume Nextcloud now uses ../apps/... for all applications.

I hacked around this with the following addition to my NGINX reverse proxy config. but it's not ideal (a 301 redirect did not work - but that is more of a problem for https://github.com/CollaboraOnline/online):

...
    # Hack for redirecting the custom_apps URL for fonts.json to apps to
    # fix the built-in CODE server's hard-coded use of the former as
    # custom_apps is replaced by apps in the URL for later versions of
    # Nextcloud.
    location = /custom_apps/richdocuments/settings/fonts.json                                                                                                                                                                                               
    {
        proxy_pass https://<Nextcloud Domain>/apps/richdocuments/settings/fonts.json;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
...
    location /
    {
...

Activity

  1. lzlrd commented on Apr 17, 2025

    @lzlrd
    Author

    The line in question where this is set seems to be https://github.com/CollaboraOnline/richdocumentscode/blob/master/proxy.php#L85.

  2. etisserant commented on May 3, 2025

    @etisserant

    +1
    This is also a problem when using nextcloud Snap package together with builtin CODE. In case of Snap packages, bundled Nextcloud read-only apps are served under /apps while other apps are under /ext-apps. Unfortunately CODE deduces richdocuments' fonts.json URL based on richdocumentscode app path, not in the same app path. I worked around hard-coding correct URL in proxy.php, until next update.

  3. JeroenvanderSluijs commented on May 23, 2025

    @JeroenvanderSluijs

    I have this same problem with snap nextcloud
    There is a bug where snap nextcloud looks for:
    /index.php/extra-apps/richdocuments/settings/fonts.json
    while it is in:
    /index.php/apps/richdocuments/settings/fonts.json

    Inspired by https://help.nextcloud.com/t/nextcloud-snap-guide-to-getting-htacces-pretty-urls/213444
    I made a workaround by changing
    /snap/nextcloud/current/htdocs/.htaccess

    by adding at the end of that file the following 3 lines of code:

    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^index.php/extra-apps/richdocuments/settings/fonts.json$ /index.php/apps/richdocuments/settings/fonts.json? [L]

    after saving one needs to restart the service by:
    sudo snap restart nextcloud.apache

    Now, the extra fonts that were added in nextcloud administration settings under Office, finally show up in the editor.

    I guess after each update this needs to be redone and I guess my workaround has room for improvement?

  4. lzlrd commented on May 27, 2025

    @lzlrd
    Author

    @etisserant and @JeroenvanderSluijs, if you could give a 👍 on the OP it should hopefully get more visibility.

  5. JeroenvanderSluijs commented on May 28, 2025

    @JeroenvanderSluijs

    I was mistaken. The rewrite rule in .htaccess does not do the job. The hard-coding of the URL in proxy.php which I tried first seems to do the job, but it requires a restart of the snap nextcloud (which I did to let the .htaccess change take effect, but in fact the hard-coding in proxy.php did the job).

    I added the following lines to /var/snap/nextcloud/current/nextcloud/extra-apps/richdocumentscode/proxy.php after line 87

    $remoteFontConfigUrl = escapeshellarg("https://YOUR.DOMAIN.HERE/index.php/apps/richdocuments/settings/fonts.json");
    $remoteFontConfig = "--o:remote_font_config.url=" . $remoteFontConfigUrl;

    after saving (and given that the command coolconfig update-system-template does not work in snap) it needs
    snap restart nextcloud

    However, modifying proxy.php seems to result in an error message in the integrity check (INVALID_HASH for proxy.php) in index.php/settings/admin/overview

    Also, after adding new fonts in index.php/settings/admin/richdocuments the system needs a snap restart nextcloud

    @lzlrd how can your solution be implemented in apache? (What file has apache's reverse proxy config and what code should I put there? )

  6. JeroenvanderSluijs commented on May 28, 2025

    @JeroenvanderSluijs

    After the latest snap nextcloud update (nextcloud 31.0.5snap1 rev.48223) the workaround in proxy.php needs to be changed to local host to avoid a 304 error when "COOLWSD HTTP Agent 24.04.13.3" tries to GET the json.fonts file:

    $remoteFontConfigUrl = escapeshellarg("https://127.0.0.1/index.php/apps/richdocuments/settings/fonts.json");

    Ignore the security warning in /index.php/settings/admin/overview (INVALID_HASH proxy.php)

    UPDATE 10 Oct 2025:

    Edit this file:
    /var/snap/nextcloud/current/nextcloud/extra-apps/richdocumentscode/proxy.php

    REPLACE_THESE_LINES

    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
    

    {
    $remoteFontConfigUrl = escapeshellarg("https://" . $_SERVER['HTTP_HOST'] . preg_replace("/richdocumentscode.*$/", "richdocuments/settings/fonts.json", $_SERVER['REQUEST_URI']));
    $remoteFontConfig = "--o:remote_font_config.url=" . $remoteFontConfigUrl;
    }

    BY_THESE_LINES

    $remoteFontConfigUrl = escapeshellarg("https://127.0.0.1/index.php/apps/richdocuments/settings/fonts.json");
    $remoteFontConfig = "--o:remote_font_config.url=" . $remoteFontConfigUrl;

    ENDREPLACEINSTRCUTION

    This does the trick for my Snap Nextcloud Hub 10 (31.0.9) install on an almalinux box.

  7. etisserant commented on Sep 8, 2025

    @etisserant

    Of course nobody cares, and of course nextcloud-snap did update CODE without asking breaking it further. Tests are overrated.

    Here is how I ended this nightmare, in the particular case of nextcloud-snap package:

    • Get back to last known working CODE. Uninstall the CODE app in nextcloud, then wget https://github.com/CollaboraOnline/richdocumentscode/releases/download/24.4.902/richdocumentscode.tar.gz, unpack it in /var/snap/nextcloud/current/nextcloud/extra-apps, enable it in NextCloud admin.
    • Fix the font URL problem. Edit /var/snap/nextcloud/current/nextcloud/extra-apps/richdocumentscode/proxy.php, change $remoteFontConfigUrl = escapeshellarg("https://" . $_SERVER['HTTP_HOST'] . preg_replace("/richdocumentscode.*$/", "richdocuments/settings/fonts.json", $_SERVER['REQUEST_URI'])); into $remoteFontConfigUrl = escapeshellarg("https://" . $_SERVER['HTTP_HOST'] . preg_replace("/extra-apps\/richdocumentscode.*$/", "apps/richdocuments/settings/fonts.json", $_SERVER['REQUEST_URI']));
    • Prevent nextcloud from being updated snap refresh --hold=forever nextcloud
    • When you want to update nextcloud's snap, prevent apps to be updated automatically. Edit /var/snap/nextcloud/current/nextcloud/config/config.php, and change 'writable' => true, into 'writable' => false,. Then update the nextcloud snap package, then revert this config.php change otherwise CODE won't start.

    Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions