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 <cursoragent@cursor.com>
This commit is contained in:
2026-02-17 12:47:00 -08:00
parent 3d9a8498fc
commit 8cd95607a4

View File

@@ -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") {