Skip auth middleware for public proxy routes

Route public paths through proxy without invoking auth so category pages no longer fail with runtime auth errors on EdgeOne.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Strtus 2026-05-19 01:11:42 +08:00
parent 6a01efce18
commit 66fa66d3d3

View File

@ -8,6 +8,7 @@ import {
PATH_OG_SAMPLE, PATH_OG_SAMPLE,
PREFIX_PHOTO, PREFIX_PHOTO,
PREFIX_TAG, PREFIX_TAG,
isPathProtected,
} from './src/app/path'; } from './src/app/path';
export function proxy(req: NextRequest, res:NextResponse) { export function proxy(req: NextRequest, res:NextResponse) {
@ -33,6 +34,12 @@ export function proxy(req: NextRequest, res:NextResponse) {
)); ));
} }
// Avoid invoking auth middleware on public routes so
// downstream auth runtime differences don't 500 category pages.
if (!isPathProtected(pathname)) {
return NextResponse.next();
}
return auth( return auth(
req as unknown as NextApiRequest, req as unknown as NextApiRequest,
res as unknown as NextApiResponse, res as unknown as NextApiResponse,