我忘了改啥了
This commit is contained in:
@@ -9,10 +9,10 @@ export async function middleware(request: NextRequest) {
|
||||
// 定义需要检查登录状态的页面
|
||||
const isRootPage = pathname === '/';
|
||||
const isLoginPage = pathname === '/login';
|
||||
const isRegisterPage = pathname === '/register';
|
||||
// 移除对注册页面的登录状态检查,允许所有用户访问注册页面
|
||||
|
||||
// 只对这三个页面进行检查
|
||||
const shouldCheckAuth = isRootPage || isLoginPage || isRegisterPage;
|
||||
// 只对首页和登录页面进行检查
|
||||
const shouldCheckAuth = isRootPage || isLoginPage;
|
||||
|
||||
if (!shouldCheckAuth) {
|
||||
return NextResponse.next();
|
||||
@@ -42,8 +42,8 @@ export async function middleware(request: NextRequest) {
|
||||
|
||||
// 配置中间件适用的路径
|
||||
export const config = {
|
||||
// 直接匹配三个目标页面
|
||||
matcher: ['/', '/login', '/register'],
|
||||
// 只匹配首页和登录页面
|
||||
matcher: ['/', '/login'],
|
||||
};
|
||||
|
||||
// 重要提示:对于(auth)路由组中的页面,Next.js路由系统会自动将'/login'和'/register'映射到正确的物理路径
|
||||
Reference in New Issue
Block a user