From bcfd144ce98f6d6b9b4bc67cf09e6e92f1020332 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 15 Apr 2024 09:57:01 +0530 Subject: [PATCH] [web] Use the public link origin provided by the server When implementing https://github.com/ente-io/ente/pull/1443 it was found that the Photos web app wasnt' using the sharedCollectionUrl prefix that is returned by the server. Instead, it was using NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT as the baseHost, while mobile client completely rely on the server for returning the correct hostUrl. **Tested by** Running against the modified server, and verifying that changes to apps.public-albums were being used. --- web/apps/photos/.env | 3 +++ web/apps/photos/src/utils/collection/index.ts | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/web/apps/photos/.env b/web/apps/photos/.env index 2680ead9fa..a039e91055 100644 --- a/web/apps/photos/.env +++ b/web/apps/photos/.env @@ -61,6 +61,9 @@ # on port 3002 (using `yarn dev:albums`), we can connect to it and emulate the # production behaviour. # +# Note: To use your custom albums endpoint in the generated public link, set the +# `apps.public-albums` property in museum's configuration. +# # Enhancement: Consider splitting this into a separate app/ in this repository. # That can also reduce bundle sizes and make it load faster. # diff --git a/web/apps/photos/src/utils/collection/index.ts b/web/apps/photos/src/utils/collection/index.ts index 9b92d794ad..b0116964f8 100644 --- a/web/apps/photos/src/utils/collection/index.ts +++ b/web/apps/photos/src/utils/collection/index.ts @@ -1,7 +1,6 @@ import { ensureElectron } from "@/next/electron"; import log from "@/next/log"; import { CustomError } from "@ente/shared/error"; -import { getAlbumsURL } from "@ente/shared/network/api"; import { LS_KEYS, getData } from "@ente/shared/storage/localStorage"; import { getUnixTimeInMicroSecondsWithDelta } from "@ente/shared/time"; import { User } from "@ente/shared/user/types"; @@ -189,11 +188,6 @@ export function appendCollectionKeyToShareURL( } const sharableURL = new URL(url); - const albumsURL = new URL(getAlbumsURL()); - - sharableURL.protocol = albumsURL.protocol; - sharableURL.host = albumsURL.host; - sharableURL.pathname = albumsURL.pathname; const bytes = Buffer.from(collectionKey, "base64"); sharableURL.hash = bs58.encode(bytes);