From 63f537a08f9bb0b1e9180dcf4bc4a8c748fb41af Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Mon, 5 Feb 2024 14:26:40 +0000 Subject: [PATCH] fix: wrap isSignupDisabled in try/catch --- apps/web/middleware.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index cab4d1ed50..1d4b84204e 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -61,10 +61,14 @@ const middleware = async (req: NextRequest): Promise> => { } if (url.pathname.startsWith("/api/auth/signup")) { - const isSignupDisabled = await get("isSignupDisabled"); - // If is in maintenance mode, point the url pathname to the maintenance page - if (isSignupDisabled) { - return NextResponse.json({ error: "Signup is disabled" }, { status: 503 }); + try { + const isSignupDisabled = await get("isSignupDisabled"); + // If is in maintenance mode, point the url pathname to the maintenance page + if (isSignupDisabled) { + return NextResponse.json({ error: "Signup is disabled" }, { status: 503 }); + } + } catch (error) { + // Don't crash if EDGE_CONFIG env var is missing } }