import type { APIEvent } from "@solidjs/start/server"; import { createServerCaller } from "~/server/api/root"; export async function GET(event: APIEvent) { const url = new URL(event.request.url); const email = url.searchParams.get("email"); const token = url.searchParams.get("token"); if (!email || !token) { return new Response( ` Email Verification Error

❌ Verification Failed

Invalid verification link. Please check your email and try again.

Return to Login
`, { status: 400, headers: { "Content-Type": "text/html" } } ); } try { const caller = await createServerCaller(event); const result = await caller.auth.emailVerification({ email, token }); if (result.success) { return new Response( ` Email Verified

Email Verified!

${result.message || "Your email has been successfully verified."}

Continue to Login
`, { status: 200, headers: { "Content-Type": "text/html" } } ); } else { throw new Error("Verification failed"); } } catch (error) { console.error("Email verification callback error:", error); const errorMessage = error instanceof Error ? error.message : "server_error"; const isTokenError = errorMessage.includes("expired") || errorMessage.includes("invalid"); return new Response( ` Email Verification Error

❌ Verification Failed

${isTokenError ? "This verification link has expired. Please request a new verification email." : "An error occurred during verification. Please try again."}

Return to Login
`, { status: 400, headers: { "Content-Type": "text/html" } } ); } }