增加tv mode开关
This commit is contained in:
@@ -4,10 +4,15 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { TOKEN_CONFIG } from '@/lib/refresh-token';
|
||||
import { isTVModeEnabled } from '@/lib/tv-mode';
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
||||
if (!isTVModeEnabled() && isTVModePath(pathname)) {
|
||||
return new NextResponse('Not Found', { status: 404 });
|
||||
}
|
||||
|
||||
// 跳过不需要认证的路径
|
||||
if (shouldSkipAuth(pathname)) {
|
||||
return NextResponse.next();
|
||||
@@ -171,6 +176,10 @@ function shouldSkipAuth(pathname: string): boolean {
|
||||
return skipPaths.some((path) => pathname.startsWith(path));
|
||||
}
|
||||
|
||||
function isTVModePath(pathname: string): boolean {
|
||||
return pathname === '/tv' || pathname.startsWith('/tv/') || pathname.startsWith('/api/tv-remote/');
|
||||
}
|
||||
|
||||
// 配置middleware匹配规则
|
||||
export const config = {
|
||||
matcher: [
|
||||
|
||||
Reference in New Issue
Block a user