mirror of
https://github.com/hexastack/hexabot
synced 2024-12-28 06:42:23 +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 = '',
|
||||
): string {
|
||||
return buildURL(
|
||||
config.parameters.apiUrl,
|
||||
config.apiPath,
|
||||
`/attachment/download/${attachmentId}/${attachmentName}`,
|
||||
);
|
||||
}
|
||||
|
@ -112,7 +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: {
|
||||
|
@ -81,7 +81,6 @@ export type Config = {
|
||||
storageMode: 'disk' | 'memory';
|
||||
maxUploadSize: number;
|
||||
appName: string;
|
||||
apiUrl: string;
|
||||
appUrl: string;
|
||||
};
|
||||
pagination: {
|
||||
|
@ -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.apiPath}${message.url}`;
|
||||
|
||||
if (!URL.canParse(url)) {
|
||||
throw new BadRequestException('Cannot parse url');
|
||||
|
@ -90,9 +90,7 @@ export class SocketRequest {
|
||||
|
||||
// Resolve the URL and path
|
||||
const urlObj = new URL(
|
||||
this.url.startsWith('http')
|
||||
? this.url
|
||||
: `${config.parameters.apiUrl}${this.url}`,
|
||||
this.url.startsWith('http') ? this.url : `${config.apiPath}${this.url}`,
|
||||
);
|
||||
this.path = urlObj.pathname || '/';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user