nextcloud / nextcloud/richdocuments
urlsrc is used verbatim from cached discovery, so the editor only works on one Nextcloud address
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 453
- Forks
- 147
- Avg merge
- 14h 54m
- Merged PRs (30d)
- 83
Description
Summary
urlsrc is taken verbatim from Collabora's cached WOPI discovery document and used directly as the editor iframe's src. Because that value is an absolute URL, a Nextcloud instance reachable at more than one address can only ever open documents on one of them.
The chain
Service/DiscoveryService::getDiscoveryEndpoint()fetches/hosting/discoveryfrom the single configuredwopi_url, and the response is cached (CachedRequestService).WOPI/Parser::getUrlSrcValue()returns theurlsrcattribute verbatim — the only transformation isstr_replace('\.', '.', …).- That value reaches the front end as
Config.get('urlsrc'), andsrc/helpers/url.js::getWopiUrl()concatenates it with the query parameters to form the iframe URL. coolwsdemits an absolute URL inurlsrc, derived from theHostof the discovery request (or fromserver_namewhen set).
So the origin baked into step 4 is fixed for every user and every session, regardless of which address they actually reached Nextcloud on.
public_wopi_url does not help: Service/ConnectivityService::autoConfigurePublicUrl() derives it from urlsrc (domainOnly($determinedUrl)) to feed the CSP. It is an output of discovery, not an override of it.
Impact
Any deployment where Nextcloud is reachable at more than one origin — a LAN address and a public domain, a .onion, split-horizon DNS — gets a working editor on exactly one of them and a blank frame on the rest. Self-hosted setups hit this routinely.
Expected
A way to have the editor load same-origin, for deployments that reverse-proxy Collabora underneath the Nextcloud origin (/browser, /cool, /hosting). Either:
- an option to strip the scheme+host from
urlsrc, leaving a root-relative URL the browser resolves against the current origin; or - treat a configured
public_wopi_urlas an override applied tourlsrc, rather than a value derived from it.
Notes
A root-relative urlsrc appears to work with no other change: nothing in the path validates it as absolute, and AddContentSecurityPolicyListener already adds 'self' as a frame domain. domainOnly('/browser/…') returns '', which getDomainList()'s array_filter drops, so no stale CSP origin is added either.
I have this working by rewriting the discovery response in the reverse proxy (Apache mod_substitute, stripping the origin from urlsrc and favIconUrl) — documents open and edit correctly on every address simultaneously. That works, but it is a workaround for something that seems like it should be configurable.
Versions: richdocuments 11.1.0, Nextcloud 34.0.3, Collabora Online Development Edition 26.04.3.2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Service/DiscoveryService::getDiscoveryEndpoint() through WOPI/Parser::getUrlSrcValue(), src/helpers/url.js::getWopiUrl(), and ConnectivityService::autoConfigurePublicUrl(). Compare the proposed same-origin and public_wopi_url approaches, then verify that documents open from multiple Nextcloud addresses while the existing CSP handling remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- backend, frontend, full-stack, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100