mirror of
https://github.com/hexastack/hexabot
synced 2024-12-28 23:02:03 +00:00
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:
commit
27925e298a
@ -75,7 +75,7 @@ const i18nOptions: I18nOptions = {
|
||||
options: {
|
||||
context: {
|
||||
appName: config.parameters.appName,
|
||||
appUrl: config.parameters.appUrl,
|
||||
appUrl: config.uiBaseUrl,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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}`,
|
||||
);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -20,7 +20,7 @@ export default [
|
||||
{
|
||||
group: CONSOLE_CHANNEL_NAMESPACE,
|
||||
label: Web.SettingLabel.allowed_domains,
|
||||
value: config.frontendPath,
|
||||
value: config.uiBaseUrl,
|
||||
type: SettingType.text,
|
||||
},
|
||||
{
|
||||
|
@ -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');
|
||||
|
@ -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 || '/';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user