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: {
|
options: {
|
||||||
context: {
|
context: {
|
||||||
appName: config.parameters.appName,
|
appName: config.parameters.appName,
|
||||||
appUrl: config.parameters.appUrl,
|
appUrl: config.uiBaseUrl,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -91,7 +91,7 @@ export class Attachment extends BaseSchema {
|
|||||||
attachmentName: string = '',
|
attachmentName: string = '',
|
||||||
): string {
|
): string {
|
||||||
return buildURL(
|
return buildURL(
|
||||||
config.parameters.apiUrl,
|
config.apiBaseUrl,
|
||||||
`/attachment/download/${attachmentId}/${attachmentName}`,
|
`/attachment/download/${attachmentId}/${attachmentName}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ export const AttachmentModel: ModelDefinition = LifecycleHookManager.attach({
|
|||||||
AttachmentModel.schema.virtual('url').get(function () {
|
AttachmentModel.schema.virtual('url').get(function () {
|
||||||
if (this._id && this.name)
|
if (this._id && this.name)
|
||||||
return buildURL(
|
return buildURL(
|
||||||
config.apiPath,
|
config.apiBaseUrl,
|
||||||
`/attachment/download/${this._id}/${this.name}`,
|
`/attachment/download/${this._id}/${this.name}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export class ContentStub extends BaseSchema {
|
|||||||
* Helper to return the internal url of this content.
|
* Helper to return the internal url of this content.
|
||||||
*/
|
*/
|
||||||
static getUrl(item: ContentElement): string {
|
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',
|
translationFilename: process.env.I18N_TRANSLATION_FILENAME || 'messages',
|
||||||
},
|
},
|
||||||
appPath: process.cwd(),
|
appPath: process.cwd(),
|
||||||
apiPath: process.env.API_ORIGIN || 'http://localhost:4000',
|
apiBaseUrl: process.env.API_ORIGIN || 'http://localhost:4000',
|
||||||
frontendPath: process.env.FRONTEND_ORIGIN
|
uiBaseUrl: process.env.FRONTEND_ORIGIN
|
||||||
? process.env.FRONTEND_ORIGIN.split(',')[0]
|
? process.env.FRONTEND_ORIGIN.split(',')[0]
|
||||||
: 'http://localhost:8080',
|
: 'http://localhost:8080',
|
||||||
security: {
|
security: {
|
||||||
@ -112,8 +112,6 @@ export const config: Config = {
|
|||||||
? Number(process.env.UPLOAD_MAX_SIZE_IN_BYTES)
|
? Number(process.env.UPLOAD_MAX_SIZE_IN_BYTES)
|
||||||
: 2000000,
|
: 2000000,
|
||||||
appName: 'Hexabot.ai',
|
appName: 'Hexabot.ai',
|
||||||
apiUrl: 'http://localhost:4000',
|
|
||||||
appUrl: 'http://localhost:8081',
|
|
||||||
},
|
},
|
||||||
pagination: {
|
pagination: {
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -27,8 +27,8 @@ type TCacheConfig = {
|
|||||||
export type Config = {
|
export type Config = {
|
||||||
i18n: { translationFilename: string };
|
i18n: { translationFilename: string };
|
||||||
appPath: string;
|
appPath: string;
|
||||||
apiPath: string;
|
apiBaseUrl: string;
|
||||||
frontendPath: string;
|
uiBaseUrl: string;
|
||||||
security: {
|
security: {
|
||||||
httpsEnabled: boolean;
|
httpsEnabled: boolean;
|
||||||
trustProxy: boolean;
|
trustProxy: boolean;
|
||||||
@ -81,8 +81,6 @@ export type Config = {
|
|||||||
storageMode: 'disk' | 'memory';
|
storageMode: 'disk' | 'memory';
|
||||||
maxUploadSize: number;
|
maxUploadSize: number;
|
||||||
appName: string;
|
appName: string;
|
||||||
apiUrl: string;
|
|
||||||
appUrl: string;
|
|
||||||
};
|
};
|
||||||
pagination: {
|
pagination: {
|
||||||
limit: number;
|
limit: number;
|
||||||
|
@ -20,7 +20,7 @@ export default [
|
|||||||
{
|
{
|
||||||
group: CONSOLE_CHANNEL_NAMESPACE,
|
group: CONSOLE_CHANNEL_NAMESPACE,
|
||||||
label: Web.SettingLabel.allowed_domains,
|
label: Web.SettingLabel.allowed_domains,
|
||||||
value: config.frontendPath,
|
value: config.uiBaseUrl,
|
||||||
type: SettingType.text,
|
type: SettingType.text,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ export class IOMessagePipe implements PipeTransform<string, IOIncomingMessage> {
|
|||||||
|
|
||||||
const url = message.url.startsWith('http')
|
const url = message.url.startsWith('http')
|
||||||
? message.url
|
? message.url
|
||||||
: `${config.parameters.apiUrl}${message.url}`;
|
: `${config.apiBaseUrl}${message.url}`;
|
||||||
|
|
||||||
if (!URL.canParse(url)) {
|
if (!URL.canParse(url)) {
|
||||||
throw new BadRequestException('Cannot parse url');
|
throw new BadRequestException('Cannot parse url');
|
||||||
|
@ -92,7 +92,7 @@ export class SocketRequest {
|
|||||||
const urlObj = new URL(
|
const urlObj = new URL(
|
||||||
this.url.startsWith('http')
|
this.url.startsWith('http')
|
||||||
? this.url
|
? this.url
|
||||||
: `${config.parameters.apiUrl}${this.url}`,
|
: `${config.apiBaseUrl}${this.url}`,
|
||||||
);
|
);
|
||||||
this.path = urlObj.pathname || '/';
|
this.path = urlObj.pathname || '/';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user