fix: 放行 PWA manifest/sw 免登录访问

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-14 22:21:33 -05:00
parent 60ea916a4d
commit abf37e9abd

View File

@ -2,13 +2,22 @@ import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const PUBLIC = ["/login", "/privacy", "/terms"];
const PUBLIC_ASSETS = [
"/manifest.webmanifest",
"/sw.js",
"/favicon.ico",
"/icon-192.png",
"/icon-512.png",
"/apple-touch-icon.png",
];
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
if (
pathname.startsWith("/_next") ||
pathname.startsWith("/favicon") ||
pathname.match(/\.(ico|png|jpg|jpeg|svg|webp|css|js)$/)
PUBLIC_ASSETS.includes(pathname) ||
pathname.match(/\.(ico|png|jpg|jpeg|svg|webp|css|js|webmanifest|map)$/)
) {
return NextResponse.next();
}