mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
add support for CloudFront headers in getLocation
This commit is contained in:
parent
04fd5d370c
commit
8df72c55e5
1 changed files with 13 additions and 0 deletions
|
|
@ -119,6 +119,19 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
|||
city,
|
||||
};
|
||||
}
|
||||
|
||||
// CloudFront headers
|
||||
if (headers.get('cloudfront-viewer-country')) {
|
||||
const country = decodeHeader(headers.get('cloudfront-viewer-country'));
|
||||
const region = decodeHeader(headers.get('cloudfront-viewer-country-region'));
|
||||
const city = decodeHeader(headers.get('cloudfront-viewer-city'));
|
||||
|
||||
return {
|
||||
country,
|
||||
region: getRegionCode(country, region),
|
||||
city,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Database lookup
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue