Repository navigation
fix(web): leave an empty server unset in the web config - #3694
Open
fredrikblau wants to merge 1 commit into
Open
fredrikblau wants to merge 1 commit into
fredrikblau wants to merge 1 commit into
Conversation
getPayload always appended a trailing slash to the configured server, so an empty WEB_UI_CONFIG_SERVER was sent to the frontend as "/". Web only falls back to the browser origin when the server is empty, so it used "/" as the API base URL and failed with "Failed to construct 'URL'". Only normalize the trailing slash when a server is set; the field is omitempty, so an empty server is now left out of config.json. Fixes opencloud-eu#3468
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Description
getPayloadalways normalized the web config'sserverto end in a slash, even when it was empty, so an emptyWEB_UI_CONFIG_SERVERwas sent to the frontend as"/". The trailing slash is now only added when a server is set. Becauseserverisomitempty, an empty value is left out ofconfig.json. Web then falls back towindow.location.origin(loadConfigonly setsserverwhen it is non-empty).Related Issue
WEB_UI_CONFIG_SERVER/OC_URL-derived Server empty still produces "/", breaking API client base URL #3468Motivation and Context
Leaving the server empty is the way to serve one instance under several hostnames. Today that breaks the web UI on load with
Failed to construct 'URL': Invalid URL, because"/"is used as the base URL for the WebDAV, Graph and OCS clients.How Has This Been Tested?
go test ./services/web/...TestGetPayloadServer, empty server:serveris absent from the payload. Without the fix it fails with"/".https://cloud.example.comandhttps://cloud.example.com///both becomehttps://cloud.example.com/, as before.Types of changes
Checklist: