AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): pass through Supabase error params in password reset callback (#12384)
Otto83e49f71cd77
diff --git a/autogpt_platform/frontend/src/app/(platform)/reset-password/page.tsx b/autogpt_platform/frontend/src/app/(platform)/reset-password/page.tsxindex 152e9037a5..b5c18d072d 100644--- a/autogpt_platform/frontend/src/app/(platform)/reset-password/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/reset-password/page.tsx@@ -42,6 +42,14 @@ function ResetPasswordContent() {if (isExpiredOrUsed) {setShowExpiredMessage(true);+ // Also show a toast with the Supabase error detail for debugging+ if (errorDescription) {+ toast({+ title: "Link Expired",+ description: errorDescription,+ variant: "destructive",+ });+ }} else {// Show toast for other errorsconst errorMessage =diff --git a/autogpt_platform/frontend/src/app/api/auth/callback/reset-password/route.ts b/autogpt_platform/frontend/src/app/api/auth/callback/reset-password/route.tsindex ddb360ff20..0ca5642bab 100644--- a/autogpt_platform/frontend/src/app/api/auth/callback/reset-password/route.ts+++ b/autogpt_platform/frontend/src/app/api/auth/callback/reset-password/route.ts@@ -9,6 +9,25 @@ export async function GET(request: NextRequest) {process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || "http://localhost:3000";if (!code) {+ // Supabase may redirect here with error params instead of a code+ // (e.g. when the OTP token is expired or already used)+ const error = searchParams.get("error");+ const errorCode = searchParams.get("error_code");+ const errorDescription = searchParams.get("error_description");++ if (error || errorCode || errorDescription) {+ // Forward raw Supabase error params to the reset-password page,+ // which already handles classification (expired vs other errors)+ const params = new URLSearchParams();+ if (error) params.set("error", error);+ if (errorCode) params.set("error_code", errorCode);+ if (errorDescription) params.set("error_description", errorDescription);++ return NextResponse.redirect(+ `${origin}/reset-password?${params.toString()}`,+ );+ }+return NextResponse.redirect(`${origin}/reset-password?error=${encodeURIComponent("Missing verification code")}`,);