feat(auth): add frontend login and route protection
This commit is contained in:
parent
6f7cae9e24
commit
4bc8b20a21
5 changed files with 116 additions and 19 deletions
18
frontend/athena/middleware.ts
Normal file
18
frontend/athena/middleware.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const token = request.cookies.get("access_token");
|
||||
|
||||
if (!token) {
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/dashboard/:path*",
|
||||
"/users/:path*",
|
||||
],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue