Skip to content

Commit d60869a

Browse files
committed
added firebase and trying ot fix thebackedn
1 parent 842f932 commit d60869a

File tree

10 files changed

+1954
-2638
lines changed

10 files changed

+1954
-2638
lines changed

middleware.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// middleware.ts
2+
import { NextResponse } from "next/server";
3+
import type { NextRequest } from "next/server";
4+
5+
export function middleware(request: NextRequest) {
6+
const token = request.cookies.get("__session")?.value;
7+
8+
// If no token and not already on /auth, redirect to login
9+
if (!token && !request.nextUrl.pathname.startsWith("/auth")) {
10+
const loginUrl = new URL("/auth", request.url);
11+
return NextResponse.redirect(loginUrl);
12+
}
13+
14+
return NextResponse.next();
15+
}
16+
17+
// Protect all routes except /auth and /_next
18+
export const config = {
19+
matcher: ["/((?!auth|_next|api|favicon.ico).*)"],
20+
};

0 commit comments

Comments
 (0)