From 8a9cd790c1ff8ea0eda2a5441ea44a1f9747fbc1 Mon Sep 17 00:00:00 2001 From: Akshay Sasidharan Date: Tue, 21 May 2024 22:15:30 +0530 Subject: [PATCH] fix TJDB query with subpath setup --- server/src/services/tooljet_db_operations.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/services/tooljet_db_operations.service.ts b/server/src/services/tooljet_db_operations.service.ts index 40582e0d94..496c87cfe0 100644 --- a/server/src/services/tooljet_db_operations.service.ts +++ b/server/src/services/tooljet_db_operations.service.ts @@ -4,6 +4,7 @@ import { QueryService, QueryResult } from '@tooljet/plugins/dist/packages/common import { TooljetDbService } from './tooljet_db.service'; import { isEmpty } from 'lodash'; import { PostgrestProxyService } from './postgrest_proxy.service'; +import { maybeSetSubPath } from 'src/helpers/utils.helper'; @Injectable() export class TooljetDbOperationsService implements QueryService { @@ -74,7 +75,7 @@ export class TooljetDbOperationsService implements QueryService { !isEmpty(offset) && query.push(`offset=${offset}`); } const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id }; - const url = `/api/tooljet-db/proxy/${tableId}` + `?${query}`; + const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}` + `?${query}`); return await this.proxyPostgrest(url, 'GET', headers); } @@ -87,7 +88,7 @@ export class TooljetDbOperationsService implements QueryService { const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id }; - const url = `/api/tooljet-db/proxy/${queryOptions.table_id}`; + const url = maybeSetSubPath(`/api/tooljet-db/proxy/${queryOptions.table_id}`); return await this.proxyPostgrest(url, 'POST', headers, columns); } @@ -112,7 +113,7 @@ export class TooljetDbOperationsService implements QueryService { !isEmpty(whereQuery) && query.push(whereQuery); const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id }; - const url = `/api/tooljet-db/proxy/${tableId}?` + query.join('&') + '&order=id'; + const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}?` + query.join('&') + '&order=id'); return await this.proxyPostgrest(url, 'PATCH', headers, body); } @@ -149,7 +150,7 @@ export class TooljetDbOperationsService implements QueryService { limit && limit !== '' && query.push(`limit=${limit}&order=id`); const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id }; - const url = `/api/tooljet-db/proxy/${tableId}?` + query.join('&'); + const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}?` + query.join('&')); return await this.proxyPostgrest(url, 'DELETE', headers); }