Fix PWA always opening marketing page instead of app home
Two-pronged fix for Android PWA shell launching to the wrong page: 1. middleware.ts: if a logged-in user (valid tia_session cookie) visits /, immediately redirect them to /home — catches all existing installs whose cached start_url still points to /?source=pwa 2. manifest.ts: change start_url from /?source=pwa to /home?source=pwa so any fresh install or reinstall opens directly to the app home Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
52ec89f5a4
commit
9c2e7328ab
3 changed files with 11 additions and 2 deletions
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@ export default function manifest(): MetadataRoute.Manifest {
|
|||
name: "Tia — Baby Tracker",
|
||||
short_name: "Tia",
|
||||
description: "Track feeds, sleep, milestones and memories.",
|
||||
start_url: "/?source=pwa",
|
||||
start_url: "/home?source=pwa",
|
||||
display: "standalone",
|
||||
background_color: "#fdf2f2",
|
||||
theme_color: "#fb7185",
|
||||
|
|
|
|||
|
|
@ -64,6 +64,15 @@ export function middleware(request: NextRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
// Logged-in users hitting the marketing root (or the old PWA start_url /?source=pwa)
|
||||
// should land on the app home, not the marketing page.
|
||||
if (pathname === "/") {
|
||||
const session = request.cookies.get("tia_session")?.value;
|
||||
if (session) {
|
||||
return NextResponse.redirect(new URL("/home", request.url));
|
||||
}
|
||||
}
|
||||
|
||||
// Always allow public routes
|
||||
for (const route of publicRoutes) {
|
||||
if (pathname === route || pathname.startsWith(route + "/")) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue