mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:51:13 -05:00
Update email cancellation and location detection functions
Refactor Supabase function to use explicit JWT verification via auth.getUser, and enhance the location detection function with configurable geolocation API endpoints. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 364fb426-1d27-49b2-a244-a34e41c335e4 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -25,10 +25,14 @@ serve(async (req) => {
|
||||
|
||||
console.log('Detecting location for IP:', clientIP);
|
||||
|
||||
// Use a free IP geolocation service with proper error handling
|
||||
// Use configurable geolocation service with proper error handling
|
||||
// Defaults to ip-api.com if not configured
|
||||
const geoApiUrl = Deno.env.get('GEOLOCATION_API_URL') || 'http://ip-api.com/json';
|
||||
const geoApiFields = Deno.env.get('GEOLOCATION_API_FIELDS') || 'status,country,countryCode';
|
||||
|
||||
let geoResponse;
|
||||
try {
|
||||
geoResponse = await fetch(`http://ip-api.com/json/${clientIP}?fields=status,country,countryCode`);
|
||||
geoResponse = await fetch(`${geoApiUrl}/${clientIP}?fields=${geoApiFields}`);
|
||||
} catch (fetchError) {
|
||||
console.error('Network error fetching location data:', fetchError);
|
||||
throw new Error('Network error: Unable to reach geolocation service');
|
||||
|
||||
Reference in New Issue
Block a user