π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Change share app to use path-based URLs via 404 fallback routing
anandbaburajan74fdbf3dd48b
diff --git a/web/apps/share/src/hooks/useFileShare.ts b/web/apps/share/src/hooks/useFileShare.tsindex 03e68db523..074456d266 100644--- a/web/apps/share/src/hooks/useFileShare.ts+++ b/web/apps/share/src/hooks/useFileShare.ts@@ -36,9 +36,10 @@ export const useFileShare = (): UseFileShareResult => {useEffect(() => {const loadFileInfo = async () => {try {- const { t: token } = router.query;+ // Extract token from pathname (e.g., /4MzPEanZK8)+ const token = window.location.pathname.slice(1);- if (!token || typeof token !== "string") {+ if (!token) {setError("Invalid file link. Missing access token.");setLoading(false);return;@@ -83,7 +84,7 @@ export const useFileShare = (): UseFileShareResult => {if (router.isReady) {void loadFileInfo();}- }, [router.isReady, router.query]);+ }, [router.isReady]);const handleDownload = async () => {if (!accessToken || !fileInfo?.fileKey) return;diff --git a/web/apps/share/src/pages/404.tsx b/web/apps/share/src/pages/404.tsxnew file mode 100644index 0000000000..414fc72877--- /dev/null+++ b/web/apps/share/src/pages/404.tsx@@ -0,0 +1,20 @@+import React from "react";+import { FileShareView } from "../components/file-share/FileShareView";++/**+ * 404 page that handles all share links with the format:+ * /4MzPEanZK8#FvDZiMigvQ8Qwh813CFUL1E2szXovnxwNoViEUpdfngE+ *+ * This page is served by static hosts (Cloudflare Pages, self-hosted servers)+ * when no matching file exists for a path. The token is extracted from the+ * pathname and the key from the hash fragment.+ *+ * This approach works without server configuration files (_redirects, etc.)+ * because static hosts automatically serve 404.html for unmatched routes+ * while preserving the URL in the browser.+ */+const NotFoundPage: React.FC = () => {+ return <FileShareView />;+};++export default NotFoundPage;diff --git a/web/apps/share/src/pages/index.tsx b/web/apps/share/src/pages/index.tsxindex 222a7c4e50..055f5d1c59 100644--- a/web/apps/share/src/pages/index.tsx+++ b/web/apps/share/src/pages/index.tsx@@ -1,24 +1,18 @@-import { useRouter } from "next/router";import React, { useEffect } from "react";-import { FileShareView } from "../components/file-share/FileShareView";+/**+ * Index page that redirects to ente.io/locker+ *+ * Users visiting the root domain (/) are redirected to the Locker homepage.+ * All share links use the format /token#key and are handled by 404.tsx.+ */const Page: React.FC = () => {- const router = useRouter();- const { t } = router.query;-useEffect(() => {- // Redirect to ente.io/locker if no token parameter- if (router.isReady && !t) {- window.location.href = "https://ente.io/locker";- }- }, [router.isReady, t]);-- // Don't render anything if redirecting- if (!t) {- return null;- }+ // Redirect to ente.io/locker+ window.location.href = "https://ente.io/locker";+ }, []);- return <FileShareView />;+ return null;};export default Page;