From b8bdc7b7125b82d403bd983193eb9561653fe37c Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 26 May 2022 11:08:53 +0530 Subject: [PATCH] fix: Support Airtable import even mapped to a different port (#2134) * fix: set default baseurl in docker and make it configurable re #2127 Signed-off-by: Pranav C * chore: update documentation Signed-off-by: Pranav C --- .../content/en/getting-started/installation.md | 1 + .../nocodb/src/lib/noco/meta/api/sync/importApis.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/noco-docs/content/en/getting-started/installation.md b/packages/noco-docs/content/en/getting-started/installation.md index a0e4e36ac9..91f4ee3ff3 100644 --- a/packages/noco-docs/content/en/getting-started/installation.md +++ b/packages/noco-docs/content/en/getting-started/installation.md @@ -207,6 +207,7 @@ By default, SQLite is used for storing meta data. However, you can specify your | NC_DISABLE_ERR_REPORT | No | Disable error reporting | | | | NC_REDIS_URL | No | Custom Redis URL. Example: `redis://:authpassword@127.0.0.1:6380/4` | Meta data will be stored in memory | | | NC_DISABLE_CACHE | No | To be used only while debugging. On setting this to `true` - meta data be fetched from db instead of redis/cache. | `false` | | +| NC_BASEURL_INTERNAL | No | Used as base url for internal(server) API calls | Default value in docker will be `http://localhost:$PORT` and in all other case it's populated from request object | | ### AWS ECS (Fargate) diff --git a/packages/nocodb/src/lib/noco/meta/api/sync/importApis.ts b/packages/nocodb/src/lib/noco/meta/api/sync/importApis.ts index 7d6e61a616..bd9d1c3295 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sync/importApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sync/importApis.ts @@ -67,12 +67,23 @@ export default (router: Router, clients: { [id: string]: Socket }) => { Noco.getConfig().auth.jwt.options ); + // Treat default baseUrl as siteUrl from req object + let baseURL = (req as any).ncSiteUrl; + + // if environment value avail use it + // or if it's docker construct using `PORT` + if (process.env.NC_BASEURL_INTERNAL) { + baseURL = process.env.NC_BASEURL_INTERNAL; + } else if (process.env.NC_DOCKER) { + baseURL = `http://localhost:${process.env.PORT || 8080}`; + } + NocoJobs.jobsMgr.add(AIRTABLE_IMPORT_JOB, { id: req.query.id, ...(syncSource?.details || {}), projectId: syncSource.project_id, authToken: token, - baseURL: (req as any).ncSiteUrl + baseURL }); res.json({}); })