···
24
24
{ name: countryInfo.name, languages: countryInfo.languages?.length || 0 } :
25
25
'Not found');
26
26
27
27
-
// For development testing only - override with a sample country
28
28
-
let dev_country = null;
29
29
-
if (!ip_country && process.env.NODE_ENV !== 'production') {
30
30
-
try {
31
31
-
const url = new URL(request.url);
32
32
-
dev_country = url.searchParams.get('country') || 'US'; // Default to US for testing
33
33
-
console.log(`[DEV] Using test country: ${dev_country}`);
34
34
-
} catch (error) {
35
35
-
console.error('Error parsing URL:', error);
36
36
-
}
37
37
-
}
38
38
-
39
27
return {
40
40
-
ip_country: ip_country || dev_country || '',
28
28
+
ip_country,
41
29
country_phone,
42
30
accept_language,
43
43
-
countryInfo,
44
44
-
// Additional info for debugging
45
45
-
source: process.env.NODE_ENV !== 'production' && !ip_country ? 'development override' : 'Cloudflare'
31
31
+
countryInfo
46
32
};
47
33
}
···
14
14
browser &&
15
15
page &&
16
16
page.data &&
17
17
-
(page.data.country || page.data.countryData || page.data.countryInfo)
17
17
+
(page.data.ip_country || page.data.countryInfo)
18
18
);
19
19
20
20
// Get current page path safely
···
22
22
browser && page && page.url ? page.url.pathname : 'unknown'
23
23
);
24
24
25
25
-
// Get Cloudflare data for debugging
26
26
-
const cloudflareData = $derived(
27
27
-
hasCloudflareData ? {
28
28
-
country: page.data.country,
29
29
-
countryData: page.data.countryData,
30
30
-
countryInfo: page.data.countryInfo,
31
31
-
rawData: page.data
32
32
-
} : null
33
33
-
);
34
34
-
35
35
-
// Default debug data if Cloudflare data is not available
36
36
-
const defaultDebugData = $derived({
37
37
-
appInfo: {
38
38
-
page: currentPath,
39
39
-
environment: import.meta.env.MODE,
40
40
-
time: new Date().toISOString()
41
41
-
}
42
42
-
});
43
43
-
44
25
// Log Cloudflare data to console on client
45
26
onMount(() => {
46
46
-
if (browser && cloudflareData) {
47
47
-
console.log('[CLIENT] Cloudflare data:', cloudflareData);
27
27
+
if (browser && page && page.data) {
28
28
+
console.log('[CLIENT] Cloudflare data:', page.data);
48
29
}
49
30
});
50
31
</script>
···
60
41
<DebugButton
61
42
title="Debug Info"
62
43
data={{
63
63
-
cloudflare: cloudflareData ? {
64
64
-
countryDetection: {
65
65
-
source: cloudflareData.countryData?.source || 'Unknown',
66
66
-
countryCode: cloudflareData.country || 'Not detected',
67
67
-
countryName: cloudflareData.countryInfo?.name || 'Not found',
68
68
-
countryFlag: cloudflareData.countryInfo?.flag || 'Not found'
69
69
-
},
70
70
-
countryInfo: cloudflareData.countryInfo ? {
71
71
-
nativeName: cloudflareData.countryInfo.native_name,
72
72
-
isoCode: cloudflareData.countryInfo.iso,
73
73
-
iso3Code: cloudflareData.countryInfo.iso3,
74
74
-
languages: cloudflareData.countryInfo.languages?.map(lang => `${lang.name} (${lang.iso}) ${lang.speakers_m ? '- ' + lang.speakers_m + 'M speakers' : ''}`) || []
75
75
-
} : null,
76
76
-
rawData: cloudflareData
44
44
+
cloudflare: hasCloudflareData ? {
45
45
+
ip_country: page.data.ip_country || '',
46
46
+
country_phone: page.data.country_phone || '',
47
47
+
accept_language: page.data.accept_language || '',
48
48
+
countryInfo: page.data.countryInfo || null
77
49
} : 'No Cloudflare data available',
78
50
appInfo: {
79
51
page: currentPath,