fix(builtin): store server_mode explicitly and derive builtin URLs server-side#5639
Draft
joshtrichards wants to merge 21 commits intomainfrom
Draft
fix(builtin): store server_mode explicitly and derive builtin URLs server-side#5639joshtrichards wants to merge 21 commits intomainfrom
joshtrichards wants to merge 21 commits intomainfrom
Conversation
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
…ing set Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
…ctivity Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix builtin CODE setup so Nextcloud no longer guesses builtin URLs from browser context.
The old flow had two architectural problems.
1. Builtin mode and
wopi_urlwere inferred from a browser-generated URL.The admin UI constructed a builtin CODE proxy URL from
window.location.hostand used it both to detect builtin mode and to savewopi_url. That only worked when Nextcloud’s internal and public URLs happened to match. In deployments with reverse proxies, split DNS, or different internal/public addresses or ports (for example container port mappings), it could select the wrong mode or save the wrong internal URL.2. Builtin
public_wopi_urlwas inferred from discovery in the wrong execution context.For standalone Collabora, deriving the public URL from
/hosting/discoveryis valid becauseserver_nameincoolwsd.xmlmakesurlsrcdeterministic. Builtin CODE behaves differently: it usesProxyPrefix, so discovery output reflects the host and scheme of the incoming request. When discovery is fetched by Nextcloud itself — during settings saves, connectivity checks, orocccommands — the returnedurlsrcreflects the server-side request context, not necessarily the browser-facing URL. That makes discovery-based public URL detection unreliable for builtin mode in proxy, split-DNS, and internal/external port-mapping setups.This change introduces an explicit
server_modeconfig key and derives builtin internal and public URLs dynamically fromIURLGeneratoron every call, so no stored value is ever consulted for builtin modeThe key design point is that builtin CODE has no independent public hostname: it is always reached through Nextcloud’s public origin. So the correct builtin public URL can be derived directly from
IURLGeneratorwithout any discovery fetch, and it stays correct automatically across domain changes. This PR also addsocc richdocuments:activate-config --builtinso CLI setup follows the same server-side derivation logic.In practice this means:
server_mode, not URL comparisonWhat changed
server_modeconfig (builtin,custom,demo)IURLGeneratorpublic_wopi_urlauto-configuration for builtin modeocc richdocuments:activate-config --builtin--forceserver_modedirectly and re-evaluate mode after async refreshwopi_urlFiles changed
lib/AppConfig.phpSERVER_MODElib/Service/ConnectivityService.phptestUrl()for validating an explicit URLautoConfigurePublicUrl()a no-op for builtin modelib/Controller/SettingsController.phpserver_modeandbuiltin_server_urlserver_modeserver_mode = 'custom'when a rawwopi_urlis savedserver_modeparameter (e.g.'demo') when one is providedlib/Settings/Admin.phpserver_modeandbuiltin_server_urlin initial statelib/Command/ActivateConfig.php--builtinand--forcesrc/components/AdminSettings.vueserver_modeinstead of URL comparison for mode selectionproxy.phpTesting
server_modeare still recognizedocc richdocuments:activate-config --builtinworks with correctoverwrite.cli.url--forceis usedChecklist