"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; export default function SuperTokensAuthComponent() { const [isLoading, setIsLoading] = useState(false); 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&redirectURIOnProviderDashboard=${encodeURIComponent(redirectUri)}` ); const data = await response.json(); if (data.status === "OK") { // Redirect to Google OAuth window.location.href = data.urlWithQueryParams; } else { console.error("Failed to get auth URL:", data); setIsLoading(false); } } catch (error) { console.error("Google sign-in error:", error); setIsLoading(false); } }; return (
By continuing, you agree to our Terms of Service and Privacy Policy.