From 00ca04591fd608be9ce9941f51c7bf6e461408a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20=C3=93skarsson?= Date: Mon, 14 Oct 2024 15:24:04 +0200 Subject: [PATCH] trying to fix geolocation --- src/actions/hello/country.ts | 2 ++ src/actions/hello/index.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/actions/hello/country.ts b/src/actions/hello/country.ts index d9eebeb..11df1ca 100644 --- a/src/actions/hello/country.ts +++ b/src/actions/hello/country.ts @@ -5,8 +5,10 @@ export async function getCountryFromIP( const res = await fetch(`http://ip-api.com/json/${ipAddress}`); const resJ = await res.json(); if (!resJ.country) { + console.warn(`[Geolocation] Received response, but no country`); return; } + console.log("country found", resJ.country); return resJ.country; } catch (_err) { console.error(`[Geolocation] Failed for ${ipAddress}`); diff --git a/src/actions/hello/index.ts b/src/actions/hello/index.ts index 0809d67..3c3c92b 100644 --- a/src/actions/hello/index.ts +++ b/src/actions/hello/index.ts @@ -46,7 +46,11 @@ export const hello = { getCountry: defineAction({ handler: async (input, ctx) => { let ip = getIPfromHeaders(ctx.request.headers); + //console.log("! getCountry", ip); if (!ip) { + //ip = "193.4.194.2"; + //ip = "77.75.80.174"; // dk + console.log("!!! No ip found for client (normal for dev)"); return; }