mirror of
https://github.com/hexastack/hexabot
synced 2024-12-28 23:02:03 +00:00
Refactor: adapt the api logic to use apiPath environment variable
This commit is contained in:
parent
dbc651a314
commit
e8751d04a3
@ -91,7 +91,7 @@ export class Attachment extends BaseSchema {
|
|||||||
attachmentName: string = '',
|
attachmentName: string = '',
|
||||||
): string {
|
): string {
|
||||||
return buildURL(
|
return buildURL(
|
||||||
config.parameters.apiUrl,
|
config.apiPath,
|
||||||
`/attachment/download/${attachmentId}/${attachmentName}`,
|
`/attachment/download/${attachmentId}/${attachmentName}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +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',
|
appUrl: 'http://localhost:8081',
|
||||||
},
|
},
|
||||||
pagination: {
|
pagination: {
|
||||||
|
@ -81,7 +81,6 @@ export type Config = {
|
|||||||
storageMode: 'disk' | 'memory';
|
storageMode: 'disk' | 'memory';
|
||||||
maxUploadSize: number;
|
maxUploadSize: number;
|
||||||
appName: string;
|
appName: string;
|
||||||
apiUrl: string;
|
|
||||||
appUrl: string;
|
appUrl: string;
|
||||||
};
|
};
|
||||||
pagination: {
|
pagination: {
|
||||||
|
@ -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.apiPath}${message.url}`;
|
||||||
|
|
||||||
if (!URL.canParse(url)) {
|
if (!URL.canParse(url)) {
|
||||||
throw new BadRequestException('Cannot parse url');
|
throw new BadRequestException('Cannot parse url');
|
||||||
|
@ -90,9 +90,7 @@ export class SocketRequest {
|
|||||||
|
|
||||||
// Resolve the URL and path
|
// Resolve the URL and path
|
||||||
const urlObj = new URL(
|
const urlObj = new URL(
|
||||||
this.url.startsWith('http')
|
this.url.startsWith('http') ? this.url : `${config.apiPath}${this.url}`,
|
||||||
? this.url
|
|
||||||
: `${config.parameters.apiUrl}${this.url}`,
|
|
||||||
);
|
);
|
||||||
this.path = urlObj.pathname || '/';
|
this.path = urlObj.pathname || '/';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user