Refactor auth session handling and server actions across app

- Overhaul `lib/auth/server.ts` and `lib/auth/session.ts`; update all API
  routes and server actions to use the revised session pattern
- Refactor server actions (settings, titles, watchlist, setup) for
  consistency with new auth layer
- Extract `SetupForm` into its own client component with `useActionState`,
  animated steps, and copyable env snippets
- Move landing page redirect logic into `app/page.tsx`; slim down
  `LandingPage` component
- Add `proxy.ts` for local dev proxying
- Minor cleanup to `NavBar`, `MobileTabBar`, and `TitleCard`
This commit is contained in:
2026-03-06 17:05:49 -05:00
parent 7a3052250d
commit 73b07f5ff6
34 changed files with 443 additions and 466 deletions
+9 -14
View File
@@ -4,19 +4,21 @@ import { type NextRequest, NextResponse } from "next/server";
const authRoutes = new Set(["/login", "/register", "/setup"]);
export function proxy(request: NextRequest) {
const sessionCookie = getSessionCookie(request);
const { pathname } = request.nextUrl;
// this is ONLY for optimistic redirects, it does not provide any actual security
const sessionCookie = getSessionCookie(request);
// Special case for root: becomes dashboard if logged in, landing page if not
if (pathname === "/") {
if (sessionCookie) {
return NextResponse.rewrite(new URL("/dashboard", request.url));
}
return NextResponse.next();
return sessionCookie
? NextResponse.rewrite(new URL("/dashboard", request.url))
: NextResponse.next();
}
// Logged-in users on auth pages → dashboard
if (authRoutes.has(pathname) && sessionCookie) {
return NextResponse.redirect(new URL("/dashboard", request.url));
return NextResponse.redirect(new URL("/", request.url));
}
// Unauthenticated users on protected pages → login
@@ -29,13 +31,6 @@ export function proxy(request: NextRequest) {
export const config = {
matcher: [
"/",
"/login",
"/register",
"/dashboard",
"/explore",
"/settings",
"/setup",
"/titles/:path*",
"/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
],
};