feat: add auth
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 15m8s

This commit is contained in:
2025-10-01 17:16:58 +07:00
parent 21b2e0ae6e
commit 018a980dcb
13 changed files with 3057 additions and 164 deletions

15
middleware.ts Normal file
View File

@ -0,0 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
import { getSessionCookie } from "better-auth/cookies";
export async function middleware(request: NextRequest) {
const sessionCookie = getSessionCookie(request);
// THIS IS NOT SECURE!
// This is the recommended approach to optimistically redirect users
// We recommend handling auth checks in each page/route
if (sessionCookie) {
return NextResponse.redirect(new URL("/", request.url));
}
return NextResponse.next();
}
export const config = {
matcher: ["/login"], // Specify the routes the middleware applies to
};