mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
add simple geolocation
This commit is contained in:
@@ -2,5 +2,13 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
|
|
||||||
export default async function ip(req: NextApiRequest, res: NextApiResponse){
|
export default async function ip(req: NextApiRequest, res: NextApiResponse){
|
||||||
let ip = req.headers['cf-connecting-ip'];
|
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
|
||||||
|
});
|
||||||
}
|
}
|
@@ -42,5 +42,8 @@ export default async function Storage(req: NextApiRequest, res: NextApiResponse)
|
|||||||
'Cache-Control',
|
'Cache-Control',
|
||||||
'public, s-maxage=10, stale-while-revalidate=59'
|
'public, s-maxage=10, stale-while-revalidate=59'
|
||||||
);
|
);
|
||||||
res.json({ object: objects, size: Number(size.toFixed(2)) });
|
res.json({
|
||||||
|
object: objects,
|
||||||
|
size: Number(size.toFixed(2))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user