Merge pull request #395 from Hexastack/390-issue-update-config-to-use-env-var-when-defining-the-apiurl-and-appurl

Update config to use env var when defining the apiUrl and appUrl
This commit is contained in:
Med Marrouchi 2024-12-02 15:44:26 +01:00 committed by GitHub
commit 27925e298a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 11 additions and 15 deletions

View File

@ -75,7 +75,7 @@ const i18nOptions: I18nOptions = {
options: {
context: {
appName: config.parameters.appName,
appUrl: config.parameters.appUrl,
appUrl: config.uiBaseUrl,
},
},
},

View File

@ -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}`,
);

View File

@ -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();
}
/**

View File

@ -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,

View File

@ -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;

View File

@ -20,7 +20,7 @@ export default [
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_domains,
value: config.frontendPath,
value: config.uiBaseUrl,
type: SettingType.text,
},
{

View File

@ -49,7 +49,7 @@ export class IOMessagePipe implements PipeTransform<string, IOIncomingMessage> {
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');

View File

@ -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 || '/';