diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 796be0cedc..3a1aa8498a 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -19,8 +19,8 @@ const middleware: NextMiddleware = async (req) => { (callbackUrl && ![CONSOLE_URL, WEBAPP_URL, WEBSITE_URL].some((u) => callbackUrl.startsWith(u))) ) { // DDOS Prevention: Immediately end request with no response - Avoids a redirect as well initiated by NextAuth on invalid callback - const res = new NextResponse("hey", { status: 400, statusText: "Please don't" }); - return res; + req.nextUrl.pathname = "/api/nope"; + return NextResponse.redirect(req.nextUrl); } } /** Display available V2 pages to users who opted-in to early access */ diff --git a/apps/web/pages/api/nope.ts b/apps/web/pages/api/nope.ts new file mode 100644 index 0000000000..ac5b83dfce --- /dev/null +++ b/apps/web/pages/api/nope.ts @@ -0,0 +1,9 @@ +import type { NextApiRequest, NextApiResponse } from "next"; + +type Response = { + message: string; +}; + +export default async function handler(req: NextApiRequest, res: NextApiResponse): Promise { + return res.status(400).json({ message: "Please don't" }); +}