我忘了改啥了

This commit is contained in:
Mikuisnotavailable
2025-10-26 00:19:23 +08:00
parent 7a36c87ff0
commit 957e7d9a15
18 changed files with 1089 additions and 512 deletions

View File

@@ -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'映射到正确的物理路径