diff --git a/lib/detect.js b/lib/detect.js index d8294f05..e5bdd733 100644 --- a/lib/detect.js +++ b/lib/detect.js @@ -79,10 +79,10 @@ export async function getClientInfo(req, { screen }) { const userAgent = req.headers['user-agent']; const ip = getIpAddress(req); const location = await getLocation(ip); - const country = location.country; - const subdivision1 = location.subdivision1; - const subdivision2 = location.subdivision2; - const city = location.city; + const country = location?.country; + const subdivision1 = location?.subdivision1; + const subdivision2 = location?.subdivision2; + const city = location?.city; const browser = browserName(userAgent); const os = detectOS(userAgent); const device = getDevice(screen, browser, os);