Check Cloudflare headers for country info. Closes #2129

This commit is contained in:
Mike Cao committed 2023-07-19 00:28:58 -07:00
1 parent b0b96b34a7
commit ccafb03c47
6 files changed
+15 -89

No files matched your search

+8
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'];