From 1b3d704b432228ebdfc2c8a298b12014cd081492 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:31:03 +0200 Subject: [PATCH] update the baseURL whenever it changes --- .../src/apps/app/app.element.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts b/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts index f4a9bb8239..6d3070339e 100644 --- a/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/apps/app/app.element.ts @@ -27,7 +27,12 @@ export class UmbAppElement extends UmbLitElement { * @remarks This is the base URL of the Umbraco server, not the base URL of the backoffice. */ @property({ type: String }) - serverUrl = window.location.origin; + set serverUrl(url: string) { + OpenAPI.BASE = url; + } + get serverUrl() { + return OpenAPI.BASE; + } /** * The base path of the backoffice. @@ -70,6 +75,8 @@ export class UmbAppElement extends UmbLitElement { constructor() { super(); + OpenAPI.BASE = window.location.origin; + new UmbContextDebugController(this); new UmbBundleExtensionInitializer(this, umbExtensionsRegistry); @@ -85,14 +92,6 @@ export class UmbAppElement extends UmbLitElement { } async #setup() { - if (this.serverUrl === undefined) throw new Error('No serverUrl provided'); - - /* All requests to the server requires the base URL to be set. - We make sure it happens before we get the server status. - TODO: find the right place to set this - */ - OpenAPI.BASE = this.serverUrl; - this.#serverConnection = await new UmbServerConnection(this.serverUrl).connect(); this.#authContext = new UmbAuthContext(this, this.serverUrl, this.backofficePath, this.bypassAuth);