Middleware rewrite shenanigans

pull/3888/head
zomars 2022-08-16 13:59:38 -06:00
parent 4f76654813
commit 79d37676fc
2 changed files with 11 additions and 2 deletions

View File

@ -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 */

View File

@ -0,0 +1,9 @@
import type { NextApiRequest, NextApiResponse } from "next";
type Response = {
message: string;
};
export default async function handler(req: NextApiRequest, res: NextApiResponse<Response>): Promise<void> {
return res.status(400).json({ message: "Please don't" });
}