π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Consolidate share app routing to use single index.tsx for all routes
Anand Baburajan8bb1a4e91930
diff --git a/docs/docs/self-hosting/installation/manual.md b/docs/docs/self-hosting/installation/manual.mdindex baedd3c427..f0ec7753d7 100644--- a/docs/docs/self-hosting/installation/manual.md+++ b/docs/docs/self-hosting/installation/manual.md@@ -228,13 +228,7 @@ git clone https://github.com/ente-io/ente:3005 {root * /var/www/ente/apps/out/sharefile_server- @root {- path /- }- handle @root {- try_files /index.html- }- try_files {path} {path}.html /404.html+ try_files {path} {path}.html /index.html}```diff --git a/web/Dockerfile b/web/Dockerfileindex 2d688ee888..c3d82421d6 100644--- a/web/Dockerfile+++ b/web/Dockerfile@@ -51,8 +51,7 @@ server {}server {listen 3005; root /out/share;- location = / { try_files /index.html =404; }- location / { try_files \$uri \$uri.html /404.html; }+ location / { try_files \$uri \$uri.html /index.html; }}EOFdiff --git a/web/apps/share/next.config.js b/web/apps/share/next.config.jsindex 5a52794ab2..9609949ba2 100644--- a/web/apps/share/next.config.js+++ b/web/apps/share/next.config.js@@ -1 +1,29 @@-module.exports = require("ente-base/next.config.base.js");+const baseConfig = require("ente-base/next.config.base.js");++module.exports = {+ ...baseConfig,+ // Disable file tracing for the share app to avoid build errors+ outputFileTracingRoot: undefined,+ experimental: {+ ...baseConfig.experimental,+ outputFileTracingIncludes: undefined,+ },+ // Only add rewrites for development (not for static export)+ async rewrites() {+ // Only apply rewrites in development mode+ if (process.env.NODE_ENV !== "production") {+ return {+ fallback: [+ {+ // Catch all routes except static files and Next.js internals+ source: "/:path((?!_next|images|favicon.ico).*)",+ destination: "/",+ },+ ],+ };+ }+ return {+ fallback: [],+ };+ },+};diff --git a/web/apps/share/package.json b/web/apps/share/package.jsonindex f4e11278a6..199593b0b0 100644--- a/web/apps/share/package.json+++ b/web/apps/share/package.json@@ -2,6 +2,9 @@"name": "share","version": "0.0.0","private": true,+ "scripts": {+ "build:post": "rm -f out/404.html"+ },"dependencies": {"ente-base": "*","hugeicons-react": "^0.3.0"diff --git a/web/apps/share/public/_redirects b/web/apps/share/public/_redirectsnew file mode 100644index 0000000000..3e05d2db4f--- /dev/null+++ b/web/apps/share/public/_redirects@@ -0,0 +1 @@+/* /index.html 200\ No newline at end of filediff --git a/web/apps/share/src/pages/404.tsx b/web/apps/share/src/pages/404.tsxdeleted file mode 100644index 129b7fb660..0000000000--- a/web/apps/share/src/pages/404.tsx+++ /dev/null@@ -1,26 +0,0 @@-import { CustomHeadShare } from "ente-base/components/Head";-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 (- <>- <CustomHeadShare title="Ente Locker" />- <FileShareView />- </>- );-};--export default NotFoundPage;diff --git a/web/apps/share/src/pages/index.tsx b/web/apps/share/src/pages/index.tsxindex 055f5d1c59..bdc854b051 100644--- a/web/apps/share/src/pages/index.tsx+++ b/web/apps/share/src/pages/index.tsx@@ -1,18 +1,46 @@-import React, { useEffect } from "react";+import { CustomHeadShare } from "ente-base/components/Head";+import React, { useEffect, useState } from "react";+import { FileShareView } from "../components/file-share/FileShareView";/**- * Index page that redirects to ente.io/locker+ * Index page that handles both root redirect and share links*- * 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.+ * - Root domain (/) redirects to ente.io/locker+ * - Share links (/token#key) render the FileShareView+ *+ * This page is served for all routes via:+ * - _redirects file for Cloudflare Pages+ * - Next.js rewrites for local development+ * - nginx try_files for Docker deployment*/const Page: React.FC = () => {+ const [isShareLink, setIsShareLink] = useState<boolean | null>(null);+useEffect(() => {- // Redirect to ente.io/locker- window.location.href = "https://ente.io/locker";+ // Check if we're at the root path+ const pathname = window.location.pathname;++ if (pathname === "/" || pathname === "") {+ // Redirect to ente.io/locker for root path+ window.location.href = "https://ente.io/locker";+ } else {+ // It's a share link, render the FileShareView+ setIsShareLink(true);+ }}, []);- return null;+ // Show nothing while determining the route+ if (isShareLink === null) {+ return null;+ }++ // Render the share view for share links+ return (+ <>+ <CustomHeadShare title="Ente Locker" />+ <FileShareView />+ </>+ );};export default Page;diff --git a/web/package.json b/web/package.jsonindex 2493974020..21e86a0a50 100644--- a/web/package.json+++ b/web/package.json@@ -14,7 +14,7 @@"build:embed": "yarn workspace embed next build","build:payments": "yarn workspace payments build","build:photos": "yarn workspace photos next build",- "build:share": "yarn workspace share next build",+ "build:share": "yarn workspace share next build && yarn workspace share build:post","dev": "yarn dev:photos","dev:accounts": "yarn workspace accounts next dev -p 3001","dev:albums": "yarn workspace photos next dev -p 3002",