Check Cloudflare headers for country info. Closes #2129

This commit is contained in:
Mike Cao 2023-07-17 00:27:42 -07:00
parent b0b96b34a7
commit ccafb03c47
6 changed files with 15 additions and 89 deletions

View file

@ -62,6 +62,14 @@ export async function getLocation(ip, req) {
return;
}
// Cloudflare headers
if (req.headers['cf-ipcountry']) {
return {
country: req.headers['cf-ipcountry'],
};
}
// Vercel headers
if (req.headers['x-vercel-ip-country']) {
const country = req.headers['x-vercel-ip-country'];
const region = req.headers['x-vercel-ip-country-region'];