Improve fresh install flow and auth page routing

- Move /setup out of protected (pages) route group so it's accessible
  without auth (fixes fresh install redirect loop)
- Redirect /login → /register when zero users exist
- Add "Get Started" button on landing page for fresh installs
- Hide register button/link when registration is closed
- Add auth redirects: logged-in users on /login or /register → /dashboard
- Convert register page to server component with server-side checks
- Fix animation snap on auth form buttons (transition-all → scoped)
- Update proxy middleware with /login and /register routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 13:58:15 -05:00
co-authored by Claude Opus 4.6
parent 6cfe3a0439
commit 3511a76508
7 changed files with 126 additions and 90 deletions
+11 -1
View File
@@ -1,6 +1,8 @@
import { getSessionCookie } from "better-auth/cookies";
import { type NextRequest, NextResponse } from "next/server";
const authRoutes = new Set(["/login", "/register"]);
export function proxy(request: NextRequest) {
const sessionCookie = getSessionCookie(request);
const { pathname } = request.nextUrl;
@@ -12,7 +14,13 @@ export function proxy(request: NextRequest) {
return NextResponse.next();
}
if (!sessionCookie) {
// Logged-in users on auth pages → dashboard
if (authRoutes.has(pathname) && sessionCookie) {
return NextResponse.redirect(new URL("/dashboard", request.url));
}
// Unauthenticated users on protected pages → login
if (!authRoutes.has(pathname) && !sessionCookie) {
return NextResponse.redirect(new URL("/login", request.url));
}
@@ -22,6 +30,8 @@ export function proxy(request: NextRequest) {
export const config = {
matcher: [
"/",
"/login",
"/register",
"/dashboard",
"/explore",
"/settings",