diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 8d6d69f8f2..b7d5faf097 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -39,10 +39,21 @@ export function checkPostMethod(req: NextRequest) { return null; } +export function checkStaticFiles(pathname: string) { + const hasFileExtension = /\.(svg|png|jpg|jpeg|gif|webp|ico)$/.test(pathname); + // Skip Next.js internal paths (_next) and static assets + if (pathname.startsWith("/_next") || hasFileExtension) { + return NextResponse.next(); + } +} + const middleware = async (req: NextRequest): Promise> => { const postCheckResult = checkPostMethod(req); if (postCheckResult) return postCheckResult; + const isStaticFile = checkStaticFiles(req.nextUrl.pathname); + if (isStaticFile) return isStaticFile; + const url = req.nextUrl; const requestHeaders = new Headers(req.headers); requestHeaders.set("x-url", req.url);