Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.3 kB ยท 34 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435import type { NextRequest } from "next/server";
import { handlers } from "@/lib/auth";
export const { POST } = handlers;
// Auth.js bounces an expired or reused magic link to `pages.error` without the// link's `callbackUrl`; carry it over as `redirectTo` so the retry still lands// on the invite.export async function GET(req: NextRequest) { const res = await handlers.GET(req); const location = res.headers.get("Location"); const callbackUrl = req.nextUrl.searchParams.get("callbackUrl"); if (!location || !callbackUrl) return res;
const target = new URL(location, req.nextUrl.origin); if (target.searchParams.get("error") !== "Verification") return res; const destination = new URL(callbackUrl, req.nextUrl.origin); if (destination.origin !== req.nextUrl.origin) return res;
target.searchParams.set( "redirectTo", `${destination.pathname}${destination.search}`, ); const headers = new Headers(res.headers); headers.set("Location", target.toString()); return new Response(null, { status: res.status, headers });}
// Mail link scanners probe magic links with HEAD. Next would route HEAD to// GET, which consumes the token; answer 200 before Auth.js sees it.export function HEAD() { return new Response(null, { status: 200 });}