From c49e2c6974eb7fd873b51475c58483503cc80a78 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Tue, 25 Apr 2023 14:52:29 -0700 Subject: [PATCH] Fixed Vercel geolocation. --- lib/detect.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/detect.ts b/lib/detect.ts index c3944dd3..36219251 100644 --- a/lib/detect.ts +++ b/lib/detect.ts @@ -62,11 +62,11 @@ export async function getLocation(ip, req) { return; } - if (process.env.VERCEL) { + if (req.headers['x-vercel-ip-country']) { return { - country: req.headers['x-vercel-ip-city'], - subdivision1: req.headers['x-vercel-ip-country-region'], - city: req.headers['x-vercel-ip-country'], + country: req.headers['x-vercel-ip-country'], + subdivision1: `${req.headers['x-vercel-ip-country']}-${req.headers['x-vercel-ip-country-region']}`, + city: req.headers['x-vercel-ip-city'], }; }