Fix verify-email redirect pointing at the internal container address

request.url reflects the container's internal 0.0.0.0:3000 behind
Caddy's reverse proxy, not the public domain — sent real browsers to an
unreachable address. Caught live during post-deploy verification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-07-22 07:31:02 +00:00
parent df05ea5358
commit adca6e0f64
+9 -1
View File
@@ -4,12 +4,20 @@ import { verifyEmailByToken } from "../../../lib/customerAuth";
// Entered from the link in the verification email — no session exists
// yet at this point. See Customers.ts's own comment on why this is a
// non-blocking flag (login already works before this is ever clicked).
//
// Base URL is deliberately NOT built from request.url — behind Caddy's
// reverse proxy that reflects the container's internal address
// (0.0.0.0:3000, confirmed live), not the public domain, and would send a
// real browser to an unreachable address. Same hardcoded-origin approach
// as Customers.ts's own FRONTEND_URL default on the Payload side.
const SITE_URL = "https://einfach-produktiv.mk360.de";
export async function GET(request: NextRequest) {
const token = request.nextUrl.searchParams.get("token");
if (!token) return new Response("Ungültiger Link.", { status: 400 });
const ok = await verifyEmailByToken(token);
const url = new URL("/konto/profil", request.url);
const url = new URL("/konto/profil", SITE_URL);
url.searchParams.set("verified", ok ? "1" : "0");
return NextResponse.redirect(url);
}