From 55a7be064264a165e9ff0319ba05eceec9c1cb3c Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 9 Dec 2022 12:40:13 +0530 Subject: [PATCH] use env override for endpoint if is dev deployment --- src/utils/collection/index.ts | 2 +- src/utils/common/apiUtil.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/collection/index.ts b/src/utils/collection/index.ts index c1e380c56..514bb6e66 100644 --- a/src/utils/collection/index.ts +++ b/src/utils/collection/index.ts @@ -126,7 +126,7 @@ export function appendCollectionKeyToShareURL( const albumsURL = new URL(getAlbumsURL()); sharableURL.protocol = albumsURL.protocol; - sharableURL.hostname = albumsURL.hostname; + sharableURL.host = albumsURL.host; sharableURL.pathname = albumsURL.pathname; const bytes = Buffer.from(collectionKey, 'base64'); diff --git a/src/utils/common/apiUtil.ts b/src/utils/common/apiUtil.ts index 3894e2632..3d28757a5 100644 --- a/src/utils/common/apiUtil.ts +++ b/src/utils/common/apiUtil.ts @@ -45,10 +45,7 @@ export const getPaymentsURL = () => { export const getAlbumsURL = () => { const albumsURL = process.env.NEXT_PUBLIC_ENTE_PAYMENT_ENDPOINT; - if ( - process.env.NEXT_PUBLIC_ENTE_DEV_APP_URL === window.location.origin && - albumsURL - ) { + if (isDevDeployment() && albumsURL) { return albumsURL; } return `https://albums.ente.io`; @@ -69,3 +66,6 @@ export const getUploadEndpoint = () => { } return `https://uploader.ente.io`; }; + +export const isDevDeployment = () => + process.env.NEXT_PUBLIC_ENTE_DEV_APP_URL === window.location.origin;