Skip to content

Commit af276ea

Browse files
committed
feat: 添加 IP 地址查询
1 parent c45895a commit af276ea

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

ip-location/index.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* IP 地址查询接口
3+
* 无 CORS
4+
*/
5+
6+
// https://ip2location.deno.dev?ip=101.67.50.27
7+
Deno.serve((req) => {
8+
const fd = new FormData();
9+
fd.set("ip", new URL(req.url).searchParams.get("ip"));
10+
return fetch("https://iplocation.com/", {
11+
headers: {
12+
accept: "*/*",
13+
"accept-language":
14+
"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
15+
priority: "u=1, i",
16+
"sec-ch-ua":
17+
'"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24"',
18+
"sec-ch-ua-mobile": "?0",
19+
"sec-ch-ua-platform": '"Windows"',
20+
"sec-fetch-dest": "empty",
21+
"sec-fetch-mode": "cors",
22+
"sec-fetch-site": "same-origin",
23+
},
24+
referrer: "https://iplocation.com/",
25+
referrerPolicy: "strict-origin-when-cross-origin",
26+
body: fd,
27+
method: "POST",
28+
mode: "cors",
29+
credentials: "include",
30+
});
31+
});

0 commit comments

Comments
 (0)