diff --git a/proxy.ts b/proxy.ts index 0b9c480c..7876c933 100644 --- a/proxy.ts +++ b/proxy.ts @@ -8,6 +8,7 @@ import { PATH_OG_SAMPLE, PREFIX_PHOTO, PREFIX_TAG, + isPathProtected, } from './src/app/path'; 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( req as unknown as NextApiRequest, res as unknown as NextApiResponse,