Spaces:
Runtime error

cybully-api / apps /web /src /middleware.ts
Oheha's picture
add error handling and timeout fallback to middleware
32b4e76
Raw History Blame Contribute Delete
855 Bytes
import { type NextRequest, NextResponse } from "next/server";
import { updateSession } from "@/utils/supabase/middleware";
export async function middleware(request: NextRequest) {
try {
return await updateSession(request);
} catch (error) {
console.error("Unhandled error in middleware:", error);
return NextResponse.next({
request: {
headers: request.headers
}
});
}
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* - Any file extension (e.g., .svg, .png, .jpg, .css, .js, etc.)
*/
"/((?!_next/static|_next/image|favicon.ico|api/|.*\\.(?:svg|png|jpg|jpeg|gif|webp|css|js|json|ico|woff|woff2|ttf)$).*)"
]
};