π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Support embed path-token links
Anand Baburajanc82f2d27ed7a
diff --git a/web/apps/albums/public/_redirects b/web/apps/albums/public/_redirectsindex 1ae3066fe3..fbaae58c90 100644--- a/web/apps/albums/public/_redirects+++ b/web/apps/albums/public/_redirects@@ -4,4 +4,3 @@/.well-known/* /.well-known/:splat 200/robots.txt /robots.txt 200/:token / 200-/:token/ / 200diff --git a/web/apps/embed/next.config.js b/web/apps/embed/next.config.jsindex 5a52794ab2..c793d2d8ba 100644--- a/web/apps/embed/next.config.js+++ b/web/apps/embed/next.config.js@@ -1 +1,20 @@-module.exports = require("ente-base/next.config.base.js");+const baseConfig = require("ente-base/next.config.base.js");++module.exports = {+ ...baseConfig,+ // Keep static export in production; in development, serve path-token links+ // through the index page so local browser loads match Cloudflare fallback.+ ...(process.env.NODE_ENV === "development" && {+ output: undefined,+ async rewrites() {+ return {+ fallback: [+ {+ source: "/:path((?!_next|images|favicon.ico).*)",+ destination: "/",+ },+ ],+ };+ },+ }),+};diff --git a/web/apps/embed/public/_redirects b/web/apps/embed/public/_redirectsnew file mode 100644index 0000000000..fbaae58c90--- /dev/null+++ b/web/apps/embed/public/_redirects@@ -0,0 +1,6 @@+/_next/* /_next/:splat 200+/fonts/* /fonts/:splat 200+/images/* /images/:splat 200+/.well-known/* /.well-known/:splat 200+/robots.txt /robots.txt 200+/:token / 200diff --git a/web/apps/embed/src/pages/index.tsx b/web/apps/embed/src/pages/index.tsxindex af9e6ae4c9..0456b556ce 100644--- a/web/apps/embed/src/pages/index.tsx+++ b/web/apps/embed/src/pages/index.tsx@@ -44,6 +44,9 @@ const isDeviceLimitExceededError = async (e: unknown) =>isHTTPErrorWithStatus(e, 429) ||(await isMuseumHTTPError(e, 403, "LINK_DEVICE_LIMIT_EXCEEDED"));+const accessTokenFromURL = (url: URL) =>+ url.searchParams.get("t") || url.pathname.split("/").find(Boolean);+export default function EmbedGallery() {const { onGenericError } = useBaseContext();const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();@@ -145,22 +148,21 @@ export default function EmbedGallery() {let redirectingToWebsite = false;try {const currentURL = new URL(window.location.href);- const t = currentURL.searchParams.get("t");+ const accessToken = accessTokenFromURL(currentURL);const ck = await extractCollectionKeyFromShareURL(currentURL);- if (!t && !ck) {+ if (!accessToken && !ck) {// Only redirect to ente.com if this is not a self-hosted instance.if (!isCustomAPIOrigin) {window.location.href = "https://ente.com";redirectingToWebsite = true;}}- if (!t || !ck) {+ if (!accessToken || !ck) {return;}collectionKey.current = ck;const collection = savedPublicCollectionByKey(ck);- const accessToken = t;const currentAPIOrigin = await apiOrigin();let accessTokenJWT: string | undefined;const linkDeviceToken = savedPublicCollectionLinkDeviceToken(