feat(web): Add Cloudflare Workers geolocation fallback

Add a minimal cfgeo Cloudflare Worker that returns coarse location
from Cloudflare's edge geolocation data. Use it as a fast default
location on load, preferring browser geolocation or an explicit
search/URL selection whenever those are available.
This commit is contained in:
abdus committed 2026-10-08 21:11:07 +02:00
1 parent e295a997a1
commit dc25633f61
5 files changed
+84 -5

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
export default {
async fetch(request) {
const cf = request.cf || {};
const body = {
latitude: cf.latitude ? Number(cf.latitude) : null,
longitude: cf.longitude ? Number(cf.longitude) : null,
city: cf.city ?? null,
region: cf.region ?? null,
country: cf.country ?? null,
timezone: cf.timezone ?? null,
postalCode: cf.postalCode ?? null,
};
return new Response(JSON.stringify(body), {
headers: {
'content-type': 'application/json',
'access-control-allow-origin': '*',
'cache-control': 'no-store',
},
});
},
};