add simple geolocation

This commit is contained in:
skidoodle 2022-10-26 23:29:23 +02:00
parent a6a33bc434
commit abf1137b3e
2 changed files with 13 additions and 2 deletions

View file

@ -2,5 +2,13 @@ import { NextApiRequest, NextApiResponse } from 'next';
export default async function ip(req: NextApiRequest, res: NextApiResponse){
let ip = req.headers['cf-connecting-ip'];
res.status(200).json({ ip: ip });
let continent = req.headers['cf-ipcontinent'];
let country = req.headers['cf-ipcountry'];
let city = req.headers['cf-ipcity'];
res.status(200).json({
ip: ip,
continent: continent,
country: country,
city: city
});
}