fixed issue
parent
2e535d86c7
commit
ae8d458126
|
@ -60,28 +60,18 @@ export async function getLocation(req, ip) {
|
|||
}
|
||||
|
||||
const result = await geoip.lookup(ip);
|
||||
console.log(result);
|
||||
if (Array.isArray(result)) {
|
||||
return {
|
||||
country: result[0]?.country,
|
||||
region: result[0]?.region,
|
||||
city: result[0]?.city,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
country: result?.country,
|
||||
region: result?.region,
|
||||
city: result?.city,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
country: result?.country,
|
||||
region: result?.region,
|
||||
city: result?.city,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getClientInfo(req, { screen }) {
|
||||
const userAgent = req.headers['user-agent'];
|
||||
const ip = getIpAddress(req);
|
||||
const country = await getLocation(req, ip).country;
|
||||
const region = await getLocation(req, ip).region;
|
||||
const city = await getLocation(req, ip).city;
|
||||
const { country, region, city } = await getLocation(req, ip);
|
||||
const browser = browserName(userAgent);
|
||||
const os = detectOS(userAgent);
|
||||
const device = getDevice(screen, browser, os);
|
||||
|
|
Loading…
Reference in New Issue