From b1aab604c70d7e817b662263770206a77e66c0de Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 28 Jun 2022 22:45:05 +0100 Subject: [PATCH] cherry picking moving release url to backend --- .github/workflows/release-develop.yml | 2 +- packages/builder/vite.config.js | 3 --- packages/frontend-core/src/api/other.js | 2 +- packages/server/src/api/controllers/dev.js | 12 ++++++++++++ packages/server/src/environment.js | 4 +++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index 3c293b1bb8..7330a7154f 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -21,7 +21,7 @@ env: # Posthog token used by ui at build time POSTHOG_TOKEN: phc_uDYOfnFt6wAbBAXkC6STjcrTpAFiWIhqgFcsC1UVO5F INTERCOM_TOKEN: ${{ secrets.INTERCOM_TOKEN }} - PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} jobs: release: diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index ff60efd960..56ffbf20f5 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -32,9 +32,6 @@ export default ({ mode }) => { process.env.INTERCOM_TOKEN ), "process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN), - "process.env.FEATURE_PREVIEW_URL": JSON.stringify( - process.env.FEATURE_PREVIEW_URL - ), }), ], optimizeDeps: { diff --git a/packages/frontend-core/src/api/other.js b/packages/frontend-core/src/api/other.js index e2cd7aac83..8eb2ff47cf 100644 --- a/packages/frontend-core/src/api/other.js +++ b/packages/frontend-core/src/api/other.js @@ -60,7 +60,7 @@ export const buildOtherEndpoints = API => ({ */ checkBetaAccess: async email => { return await API.get({ - url: `${process.env.FEATURE_PREVIEW_URL}/api/beta/access?email=${email}`, + url: `/api/beta/access?email=${email}`, }) }, }) diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index 0ed3934c6c..3c249f5cab 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -140,6 +140,17 @@ exports.getBudibaseVersion = async ctx => { // TODO: remove as part of beta program exports.checkBetaAccess = async ctx => { + // go to the cloud platform if running self hosted + if (env.SELF_HOSTED || !env.MULTI_TENANCY) { + const baseUrl = env.ACCOUNT_PORTAL_URL.replace("account.", "") + const response = await fetch( + `${baseUrl}/api/beta/access?email=${ctx.query.email}` + ) + const json = await response.json() + ctx.body = json + return + } + const userToCheck = ctx.query.email const BETA_USERS_DB = "app_bb_f9b77d06b9db4e3ca185476ab87a2364" const BETA_USERS_TABLE = "ta_8c2c6df1c03f49cfb6340e85e066dd15" @@ -163,6 +174,7 @@ exports.checkBetaAccess = async ctx => { } ctx.body = { access } } catch (err) { + console.error(err) ctx.body = { access: false } } } diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 56d05684b0..bf7e7f4709 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -67,7 +67,9 @@ module.exports = { SALT_ROUNDS: process.env.SALT_ROUNDS, LOGGER: process.env.LOGGER, LOG_LEVEL: process.env.LOG_LEVEL, - AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS, + ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL, + AUTOMATION_MAX_ITERATIONS: + parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200, SENDGRID_API_KEY: process.env.SENDGRID_API_KEY, DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT, QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),