fix: wrap isSignupDisabled in try/catch

This commit is contained in:
Alex van Andel
2024-02-05 14:26:40 +00:00
parent bed593c835
commit 63f537a08f
+8 -4
View File
@@ -61,10 +61,14 @@ const middleware = async (req: NextRequest): Promise<NextResponse<unknown>> => {
}
if (url.pathname.startsWith("/api/auth/signup")) {
const isSignupDisabled = await get<boolean>("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<boolean>("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
}
}