Make OAuth URLs production-ready using NEXT_PUBLIC_APP_URL
- Remove hardcoded /leopost path from Google OAuth redirect - Use environment variable for flexible deployment URL - Fallback to window.location.origin for local development Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,13 +32,16 @@ export function GoogleSignInButton() {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const supabase = createClient()
|
const supabase = createClient()
|
||||||
|
|
||||||
|
// Use configured APP_URL for OAuth callback
|
||||||
|
const appUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin
|
||||||
|
|
||||||
async function handleGoogleSignIn() {
|
async function handleGoogleSignIn() {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
const { error } = await supabase.auth.signInWithOAuth({
|
const { error } = await supabase.auth.signInWithOAuth({
|
||||||
provider: 'google',
|
provider: 'google',
|
||||||
options: {
|
options: {
|
||||||
redirectTo: `${window.location.origin}/leopost/auth/callback/`,
|
redirectTo: `${appUrl}/auth/callback/`,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
access_type: 'offline',
|
access_type: 'offline',
|
||||||
prompt: 'consent',
|
prompt: 'consent',
|
||||||
|
|||||||
Reference in New Issue
Block a user