mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 20:15:41 +01:00
Allow send custom location from server
This commit is contained in:
parent
bce70c1034
commit
a97b43e1c4
1 changed files with 17 additions and 0 deletions
|
|
@ -81,6 +81,23 @@ export async function getLocation(ip: string, req: NextApiRequestCollect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const customHeader = String(process.env.CLIENT_IPCOUNTRY_HEADER).toLowerCase();
|
||||||
|
|
||||||
|
if (customHeader !== 'undefined' && req.headers[customHeader]) {
|
||||||
|
const reginCodeHeader = String(process.env.CLIENT_REGION_CODE_HEADER).toLowerCase();
|
||||||
|
const cityHeader = String(process.env.CLIENT_CITY_HEADER).toLowerCase();
|
||||||
|
|
||||||
|
const country = req.headers[customHeader];
|
||||||
|
const subdivision1 = req.headers[reginCodeHeader];
|
||||||
|
const city = req.headers[cityHeader];
|
||||||
|
|
||||||
|
return {
|
||||||
|
country,
|
||||||
|
subdivision1: getRegionCode(country, subdivision1),
|
||||||
|
city,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Cloudflare headers
|
// Cloudflare headers
|
||||||
if (req.headers['cf-ipcountry']) {
|
if (req.headers['cf-ipcountry']) {
|
||||||
const country = safeDecodeCfHeader(req.headers['cf-ipcountry']);
|
const country = safeDecodeCfHeader(req.headers['cf-ipcountry']);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue