首次发布git
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
export default function proxy(request: NextRequest) {
|
||||
const authCookie = request.cookies.get('auth');
|
||||
const isLoginPage = request.nextUrl.pathname === '/login';
|
||||
|
||||
if (!authCookie && !isLoginPage) {
|
||||
return NextResponse.redirect(new URL('/login', request.url));
|
||||
}
|
||||
|
||||
if (authCookie && isLoginPage) {
|
||||
return NextResponse.redirect(new URL('/', request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
|
||||
};
|
||||
Reference in New Issue
Block a user