diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 95efaf87d0..cab4d1ed50 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -60,6 +60,14 @@ const middleware = async (req: NextRequest): Promise> => { requestHeaders.set("x-cal-timezone", req.headers.get("x-vercel-ip-timezone") ?? ""); } + 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 }); + } + } + if (url.pathname.startsWith("/auth/login") || url.pathname.startsWith("/login")) { // Use this header to actually enforce CSP, otherwise it is running in Report Only mode on all pages. requestHeaders.set("x-csp-enforce", "true"); @@ -114,6 +122,7 @@ export const config = { // https://github.com/vercel/next.js/discussions/42458 matcher: [ "/:path*/embed", + "/api/auth/signup", "/api/trpc/:path*", "/login", "/auth/login",