diff --git a/next.config.js b/next.config.js index 2a33f6c64..4a46dcfac 100644 --- a/next.config.js +++ b/next.config.js @@ -36,6 +36,7 @@ module.exports = (phase) => }, env: { SENTRY_RELEASE: GIT_SHA, + NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE, }, headers() { diff --git a/src/utils/common/apiUtil.ts b/src/utils/common/apiUtil.ts index 4b8d5b7c6..cb5c41055 100644 --- a/src/utils/common/apiUtil.ts +++ b/src/utils/common/apiUtil.ts @@ -1,7 +1,12 @@ +import { getData, LS_KEYS } from 'utils/storage/localStorage'; import { runningInBrowser } from '.'; export const getEndpoint = () => { - const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT; + let endpoint = getData(LS_KEYS.API_ENDPOINT); + if (endpoint) { + return endpoint; + } + endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT; if (isDevDeployment() && endpoint) { return endpoint; } @@ -91,6 +96,7 @@ const isDevDeployment = () => { window.location.origin || process.env.NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT === window.location.origin || + process.env.NEXT_PUBLIC_IS_TEST_APP === 'true' || process.env.NODE_ENV === 'development' ); } diff --git a/src/utils/storage/localStorage.ts b/src/utils/storage/localStorage.ts index 04443b1db..9cd19b75b 100644 --- a/src/utils/storage/localStorage.ts +++ b/src/utils/storage/localStorage.ts @@ -19,6 +19,7 @@ export enum LS_KEYS { USER_DETAILS = 'userDetails', COLLECTION_SORT_BY = 'collectionSortBy', THEME = 'theme', + API_ENDPOINT = 'apiEndpoint', } export const setData = (key: LS_KEYS, value: object) => {