From 65c52e645d3b125e24b28a6e5ce4fe8de97752ff Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Mon, 2 Dec 2024 10:27:27 +0100 Subject: [PATCH] fix: update environment variables names --- api/src/app.module.ts | 2 +- api/src/attachment/schemas/attachment.schema.ts | 4 ++-- api/src/cms/schemas/content.schema.ts | 2 +- api/src/config/index.ts | 4 ++-- api/src/config/types.ts | 4 ++-- api/src/extensions/channels/console/settings.ts | 2 +- api/src/websocket/pipes/io-message.pipe.ts | 2 +- api/src/websocket/utils/socket-request.ts | 4 +++- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/api/src/app.module.ts b/api/src/app.module.ts index 2042b6c8..52b779d6 100644 --- a/api/src/app.module.ts +++ b/api/src/app.module.ts @@ -75,7 +75,7 @@ const i18nOptions: I18nOptions = { options: { context: { appName: config.parameters.appName, - appUrl: config.frontendPath, + appUrl: config.uiBaseUrl, }, }, }, diff --git a/api/src/attachment/schemas/attachment.schema.ts b/api/src/attachment/schemas/attachment.schema.ts index c68cfa9c..fed8dd90 100644 --- a/api/src/attachment/schemas/attachment.schema.ts +++ b/api/src/attachment/schemas/attachment.schema.ts @@ -91,7 +91,7 @@ export class Attachment extends BaseSchema { attachmentName: string = '', ): string { return buildURL( - config.apiPath, + config.apiBaseUrl, `/attachment/download/${attachmentId}/${attachmentName}`, ); } @@ -124,7 +124,7 @@ export const AttachmentModel: ModelDefinition = LifecycleHookManager.attach({ AttachmentModel.schema.virtual('url').get(function () { if (this._id && this.name) return buildURL( - config.apiPath, + config.apiBaseUrl, `/attachment/download/${this._id}/${this.name}`, ); diff --git a/api/src/cms/schemas/content.schema.ts b/api/src/cms/schemas/content.schema.ts index 173f84b5..16a2cd06 100644 --- a/api/src/cms/schemas/content.schema.ts +++ b/api/src/cms/schemas/content.schema.ts @@ -53,7 +53,7 @@ export class ContentStub extends BaseSchema { * Helper to return the internal url of this content. */ static getUrl(item: ContentElement): string { - return new URL('/content/view/' + item.id, config.apiPath).toString(); + return new URL('/content/view/' + item.id, config.apiBaseUrl).toString(); } /** diff --git a/api/src/config/index.ts b/api/src/config/index.ts index 8829551a..223783fd 100644 --- a/api/src/config/index.ts +++ b/api/src/config/index.ts @@ -15,8 +15,8 @@ export const config: Config = { translationFilename: process.env.I18N_TRANSLATION_FILENAME || 'messages', }, appPath: process.cwd(), - apiPath: process.env.API_ORIGIN || 'http://localhost:4000', - frontendPath: process.env.FRONTEND_ORIGIN + apiBaseUrl: process.env.API_ORIGIN || 'http://localhost:4000', + uiBaseUrl: process.env.FRONTEND_ORIGIN ? process.env.FRONTEND_ORIGIN.split(',')[0] : 'http://localhost:8080', security: { diff --git a/api/src/config/types.ts b/api/src/config/types.ts index 5f0f340b..7d63613d 100644 --- a/api/src/config/types.ts +++ b/api/src/config/types.ts @@ -27,8 +27,8 @@ type TCacheConfig = { export type Config = { i18n: { translationFilename: string }; appPath: string; - apiPath: string; - frontendPath: string; + apiBaseUrl: string; + uiBaseUrl: string; security: { httpsEnabled: boolean; trustProxy: boolean; diff --git a/api/src/extensions/channels/console/settings.ts b/api/src/extensions/channels/console/settings.ts index d0e5abac..4f877c84 100644 --- a/api/src/extensions/channels/console/settings.ts +++ b/api/src/extensions/channels/console/settings.ts @@ -20,7 +20,7 @@ export default [ { group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.allowed_domains, - value: config.frontendPath, + value: config.uiBaseUrl, type: SettingType.text, }, { diff --git a/api/src/websocket/pipes/io-message.pipe.ts b/api/src/websocket/pipes/io-message.pipe.ts index 798ad5ab..102247a0 100644 --- a/api/src/websocket/pipes/io-message.pipe.ts +++ b/api/src/websocket/pipes/io-message.pipe.ts @@ -49,7 +49,7 @@ export class IOMessagePipe implements PipeTransform { const url = message.url.startsWith('http') ? message.url - : `${config.apiPath}${message.url}`; + : `${config.apiBaseUrl}${message.url}`; if (!URL.canParse(url)) { throw new BadRequestException('Cannot parse url'); diff --git a/api/src/websocket/utils/socket-request.ts b/api/src/websocket/utils/socket-request.ts index 25c5fab3..3b58cd22 100644 --- a/api/src/websocket/utils/socket-request.ts +++ b/api/src/websocket/utils/socket-request.ts @@ -90,7 +90,9 @@ export class SocketRequest { // Resolve the URL and path const urlObj = new URL( - this.url.startsWith('http') ? this.url : `${config.apiPath}${this.url}`, + this.url.startsWith('http') + ? this.url + : `${config.apiBaseUrl}${this.url}`, ); this.path = urlObj.pathname || '/';