Fix: Get IP API

没获取 Query 里面的 IP
This commit is contained in:
奇趣保罗 2022-07-04 17:59:36 +08:00
parent 653f90f258
commit b47fbfc03b
1 changed files with 1 additions and 1 deletions

View File

@ -23,7 +23,7 @@ export default Api(
// 增加使用数量 // 增加使用数量
await client.incr("api-next:stat:ip"); await client.incr("api-next:stat:ip");
const ip = ctx.headers["x-forwarded-for"] || ctx.request.ip.replace(/::\S+:/, "") || "127.0.0.1"; const ip = ctx.query.ip || ctx.headers["x-forwarded-for"] || ctx.request.ip.replace(/::\S+:/, "") || "127.0.0.1";
const response = await fetch(`http://ip-api.com/json/${ip}?lang=zh-CN`, { const response = await fetch(`http://ip-api.com/json/${ip}?lang=zh-CN`, {
headers: { headers: {