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:
@@ -10,8 +10,14 @@ export default function SuperTokensAuthComponent() {
|
|||||||
const handleGoogleSignIn = async () => {
|
const handleGoogleSignIn = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
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
|
// 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();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.status === "OK") {
|
if (data.status === "OK") {
|
||||||
|
|||||||
Reference in New Issue
Block a user