From 3d4b66137085b23ff9aac0286828563256818d6b Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Mon, 9 Feb 2026 16:46:02 -0600 Subject: [PATCH] fix: improve Turnstile configuration - handle web/mobile differences, add error callbacks --- .../lib/widgets/auth/turnstile_widget.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sojorn_app/lib/widgets/auth/turnstile_widget.dart b/sojorn_app/lib/widgets/auth/turnstile_widget.dart index 571e916..c8b401d 100644 --- a/sojorn_app/lib/widgets/auth/turnstile_widget.dart +++ b/sojorn_app/lib/widgets/auth/turnstile_widget.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:cloudflare_turnstile/cloudflare_turnstile.dart'; import 'package:flutter/material.dart'; import '../../config/api_config.dart'; @@ -16,10 +17,24 @@ class TurnstileWidget extends StatelessWidget { @override Widget build(BuildContext context) { + // On web, use the full API URL + // On mobile, Turnstile handles its own endpoints + final effectiveBaseUrl = kIsWeb ? (baseUrl ?? ApiConfig.baseUrl) : null; + return CloudflareTurnstile( siteKey: siteKey, - baseUrl: baseUrl ?? ApiConfig.baseUrl, + baseUrl: effectiveBaseUrl, onTokenReceived: onToken, + onError: (error) { + if (kDebugMode) { + print('Turnstile error: $error'); + } + }, + onExpired: () { + if (kDebugMode) { + print('Turnstile token expired'); + } + }, ); } }