From 8cd95607a4a1639b880c5631e5d5f602e1bcf593 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Tue, 17 Feb 2026 12:47:00 -0800 Subject: [PATCH] Fix Google OAuth: add redirectURIOnProviderDashboard parameter - SuperTokens requires redirectURIOnProviderDashboard param - Construct it from NEXT_PUBLIC_APP_URL or window.location.origin - Properly encode the redirect URI in the query string - Fixes 400 error: 'Please provide the redirectURIOnProviderDashboard' Co-authored-by: Cursor --- app/components/SuperTokensAuthComponent.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/SuperTokensAuthComponent.tsx b/app/components/SuperTokensAuthComponent.tsx index e0cb8c4..c4fa427 100644 --- a/app/components/SuperTokensAuthComponent.tsx +++ b/app/components/SuperTokensAuthComponent.tsx @@ -10,8 +10,14 @@ export default function SuperTokensAuthComponent() { const handleGoogleSignIn = async () => { setIsLoading(true); try { + // Get the base URL from environment or current window + const baseUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin; + const redirectUri = `${baseUrl}/api/auth/callback/google`; + // Get Google OAuth URL from SuperTokens - const response = await fetch("/api/auth/authorisationurl?thirdPartyId=google"); + const response = await fetch( + `/api/auth/authorisationurl?thirdPartyId=google&redirectURIOnProviderDashboard=${encodeURIComponent(redirectUri)}` + ); const data = await response.json(); if (data.status === "OK") {