From 3ad29a504ca6be6e473b3f47d303856054bcc98f Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 10 Feb 2024 15:32:01 +0530 Subject: [PATCH] Move to a singular flag This might not be enough if we also want to cater for development desktop builds, but let's start with this and add them back later if needed. --- packages/shared/network/api.ts | 52 ++++++---------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/packages/shared/network/api.ts b/packages/shared/network/api.ts index 329699a95..39838e1b1 100644 --- a/packages/shared/network/api.ts +++ b/packages/shared/network/api.ts @@ -73,50 +73,16 @@ export const getFamilyPortalURL = () => { }; /** - * A build is considered as a development build if one of the following holds: + * A build is considered as a development build if the NODE_ENV environment + * variable is set to 'development'. * - * 1. The NODE_ENV environment variable is set to 'development'. This - * automatically happens when we run `yarn dev:foo`, but we can also - * explictly set this to development before invoking the build. From the - * Next.js docs: + * This automatically happens when we run `yarn dev:foo`, but we can also + * explictly set it to development before invoking the build. From Next.js docs: * - * > If the environment variable NODE_ENV is unassigned, Next.js - * > automatically assigns development when running the `next dev` command, - * > or production for all other commands. - * - * 2. Sometimes we're building for a remote deployment, but we want the deployed - site to behave as a development build. For example, when deploying the - main branch to `testing.ente.io`. In these cases, since the build was done - using `yarn export` (which in turn invokes `next build`), the NODE_ENV - will not get set to 'development'. To handle such cases, we introduce - another variable, NEXT_PUBLIC_ENTE_ENV, which has the same semantics as - * - * - * If the environment variable NODE_ENV is unassigned, Next.js automatically - assigns development when running the next dev command, or production for all - other commands. - * next sets NODE_ENV to `production`. - * When we run - * `yarn dev:foo`, it invokes `next dev`, which sets NODE_ENV to - * 'development'. In all other cases (say, `next build`), - * - -It's a dev deployment (and should use the environment override for endpoints ) -in three cases: -1. when the URL opened is that of the staging web app, or -2. when the URL opened is that of the staging album app, or -3. if the app is running locally (hence node_env is development) -4. if the app is running in test mode -*/ + * > If the environment variable NODE_ENV is unassigned, Next.js + * automatically assigns development when running the `next dev` command, + * or production for all other commands. + */ export const isDevDeployment = () => { - if (globalThis?.location) { - return ( - process.env.NEXT_PUBLIC_ENTE_WEB_ENDPOINT === - globalThis.location.origin || - process.env.NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT === - globalThis.location.origin || - process.env.NEXT_PUBLIC_IS_TEST_APP === 'true' || - process.env.NODE_ENV === 'development' - ); - } + return process.env.NODE_ENV === 'development'; };