Skip to content

fix(example): fetch callback links from the internal address - #22

Merged
bhumigopaniStarto merged 2 commits into
mainfrom
fix/example-internal-download-url
Nov 6, 2026
Merged

bhumigopaniStarto merged 2 commits into
mainfrom
fix/example-internal-download-url

Conversation

@rikled

@rikled rikled commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Problem

With the documented -p 8080:80 and EXAMPLE_ENABLED=true, edits made in the example are never saved to storage.

The document server builds callback links from the address the browser used (http://localhost:8080/cache/files/...). The example runs inside the same container, where nothing listens on 8080, so the download fails with ECONNREFUSED. The server then stores the changes as forgotten, and every later open shows:

This file is opened from a server backup copy and is not saved to storage.

Fix

  • New server.internalSiteUrl setting: the address this backend uses to reach the document server. null in default.json, so nothing is rewritten unless it is set.
  • url, changesurl and formsdataurl from a callback are fetched from that address. A proxy prefix in front of /cache/files is dropped, because that path only exists on the public address. All three are needed: fixing only url would still fail on the changesurl download.
  • Standalone: production-linux.json sets http://localhost/, because the example runs next to nginx.
  • Orchestrated: the example image also loads production-linux.json, but runs in its own container, where localhost is not the document server. docker-entrypoint.sh therefore overrides the setting from the new optional DS_INTERNAL_URL. When unset it is empty and links are fetched unchanged, as they are today.

Testing

Each case typed text in a real editor, closed it, then checked the stored file and reopened it.

Setup Text in stored file Forgotten Backup warning
Standalone, -p 8092:80, stock example (baseline) No Yes Yes
Standalone, patched Yes No No
Split, DS_INTERNAL_URL unset Yes No No
Split, DS_INTERNAL_URL=http://ds/ Yes No No
Split, DS_INTERNAL_URL=http://localhost/ (negative control, first run only) No Yes Yes
Standalone behind a subpath proxy, without prefix handling No (404) Yes Yes
Standalone behind a subpath proxy, final code Yes No No
Standalone, real hostname instead of localhost Yes No No

The negative control shows why production-linux.json alone would have broken orchestrated deployments. diff.zip was also written to the version history in the standalone run. eslint passes on app.js.

Limits of this testing:

  • The full standalone and split runs predate the prefix commit. Paths without a prefix produce the same result, checked directly on the rewrite, and the subpath run covers the final code in standalone.
  • The subpath runs used a small test proxy with siteUrl set to /office/. With the standalone default /, the editor does not load under a subpath at all, with or without this PR.
  • The patched example ran from source on Node 20 over the documentserver-build-cache:pr-508 image, not from a rebuilt image.
  • "Split" means two containers on a shared Docker network using the real docker-entrypoint.sh and production-linux config, not the actual cluster-example image.
  • Force save and formsdataurl go through the same helper but were not exercised.

Things to review

  • Package installs: these also load production-linux.json. If nginx there is moved off port 80, http://localhost/ would be wrong, so saves would need internalSiteUrl set in local.json. I have not tested package installs.
  • Rollout: DocumentServer needs a submodule bump for this to reach the images.

🤖 Generated with Claude Code

The document server builds the links in a callback from the address the
browser used. With the documented "-p 8080:80" that port only exists on the
docker host, so the example could not download the saved file: the callback
failed with ECONNREFUSED, the changes went to the forgotten folder and every
later open warned that the file came from a server backup copy.

server.internalSiteUrl now names the address this backend reaches the document
server on, and the url, changesurl and formsdataurl of a callback are fetched
from it. It is http://localhost/ in production-linux.json, where the example
runs next to nginx.

The orchestrated example loads the same file from its own container, where
localhost is not the document server, so docker-entrypoint.sh overrides it from
DS_INTERNAL_URL. Left unset, links are fetched as they are, as before.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
A proxy on a subpath puts its prefix in front of /cache/files in the links the
document server builds. That path only exists on the public address, so
fetching it from internalSiteUrl returned 404 and the changes went to the
forgotten folder. Start the path at /cache/files when fetching it internally.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
@bhumigopaniStarto

Copy link
Copy Markdown
Contributor

Testing status: positive check, passes

Scenario tested

  • Document server: ghcr.io/euro-office/documentserver:latest (digest sha256:2fadc1b3dc99250d6576fc0c0f34349db6725b752b08e91db9831fbb803fc5c2), run with -p 8080:80 and JWT_ENABLED=false.
  • Example: Node.js example from source at this PR's branch, on Node v22.22.1 and port 3000. It is not a rebuilt image.
  • Config for the example:
    • siteUrl=http://localhost:8080/
    • exampleUrl=http://host.docker.internal:3000
    • internalSiteUrl=http://localhost:8080/
  • Steps: I opened several documents at http://localhost:3000, typed text, closed the editor, and reopened the files.

Observations

  • The saved files kept all the typed text, with no "opened from a server backup copy" warning.
  • Setting internalSiteUrl doesn't break the callback download and save flow.

Limits

  • The example ran on the host, not inside the document server container, so localhost:8080 was reachable with or without this fix. This test doesn't reproduce the original ECONNREFUSED. It only shows the change doesn't regress saving.
  • I didn't test force save, formsdataurl, a subpath proxy, the split-container setup with DS_INTERNAL_URL, or package installs.
  • To get the example to run locally, I had to do three things that are not part of the PR:
    • Initialise the asset submodules.
    • Set appName through NODE_CONFIG.
    • Set allowPrivateIPAddress on the test document server, because it blocks private IPs by default.

@bhumigopaniStarto bhumigopaniStarto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@bhumigopaniStarto
bhumigopaniStarto merged commit 17d5a29 into main Nov 6, 2026
6 of 7 checks passed
@bhumigopaniStarto

Copy link
Copy Markdown
Contributor

Also tested in image form.

Details -
docker run -d --name ds-dsi-test -p 8080:80
-e JWT_SECRET=euro-office-dev-jwt-secret-key-2026
-e EXAMPLE_ENABLED=true -e WOPI_ENABLED=true
ghcr.io/euro-office/documentserver-dev:document-server-integration-main-f71296
curl -sf http://localhost:8080/healthcheck

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants