diff --git a/api/src/app.module.ts b/api/src/app.module.ts index 9c90f471..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.parameters.appUrl, + appUrl: config.uiBaseUrl, }, }, }, diff --git a/api/src/attachment/schemas/attachment.schema.ts b/api/src/attachment/schemas/attachment.schema.ts index 6d042ba5..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.parameters.apiUrl, + 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 5cb430a6..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: { @@ -112,8 +112,6 @@ export const config: Config = { ? Number(process.env.UPLOAD_MAX_SIZE_IN_BYTES) : 2000000, appName: 'Hexabot.ai', - apiUrl: 'http://localhost:4000', - appUrl: 'http://localhost:8081', }, pagination: { limit: 10, diff --git a/api/src/config/types.ts b/api/src/config/types.ts index 7b472909..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; @@ -81,8 +81,6 @@ export type Config = { storageMode: 'disk' | 'memory'; maxUploadSize: number; appName: string; - apiUrl: string; - appUrl: string; }; pagination: { limit: number; 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 3754f07f..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.parameters.apiUrl}${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 cd1d459f..3b58cd22 100644 --- a/api/src/websocket/utils/socket-request.ts +++ b/api/src/websocket/utils/socket-request.ts @@ -92,7 +92,7 @@ export class SocketRequest { const urlObj = new URL( this.url.startsWith('http') ? this.url - : `${config.parameters.apiUrl}${this.url}`, + : `${config.apiBaseUrl}${this.url}`, ); this.path = urlObj.pathname || '/';