Skip to content

fix(web): leave an empty server unset in the web config - #3694

Open
fredrikblau wants to merge 1 commit into
opencloud-eu:mainfrom
fredrikblau:fix/3468-empty-web-server
Open

fredrikblau wants to merge 1 commit into
opencloud-eu:mainfrom
fredrikblau:fix/3468-empty-web-server

Conversation

@fredrikblau

Copy link
Copy Markdown

Description

getPayload always normalized the web config's server to end in a slash, even when it was empty, so an empty WEB_UI_CONFIG_SERVER was sent to the frontend as "/". The trailing slash is now only added when a server is set. Because server is omitempty, an empty value is left out of config.json. Web then falls back to window.location.origin (loadConfig only sets server when it is non-empty).

Related Issue

Motivation 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?

  • test environment: go test ./services/web/...
  • test case 1: new TestGetPayloadServer, empty server: server is absent from the payload. Without the fix it fails with "/".
  • test case 2: https://cloud.example.com and https://cloud.example.com/// both become https://cloud.example.com/, as before.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

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
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

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.

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.

Setting WEB_UI_CONFIG_SERVER/OC_URL-derived Server empty still produces "/", breaking API client base URL

1 participant