- Notifications
You must be signed in to change notification settings - Fork95
利用 Cloudflare Workers / Vercel Edge / Netlify Edge 快速搭一个获取 IP 地址和地理位置信息的接口。
NotificationsYou must be signed in to change notification settings
ccbikai/ip-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
利用 Cloudflare Workers / Vercel Edge / Netlify Edge 快速搭一个获取 IP 地址和地理位置信息的接口。
- 通过访问 Cloudflare 获取本机 IP:
curl https://cloudflare-ip.html.zone/
或者直接访问https://cloudflare-ip.html.zone/ - 通过访问 Vercel 获取本机 IP:
curl https://vercel-ip.html.zone/
或者直接访问https://vercel-ip.html.zone/ - 通过访问 Netlify 获取本机 IP:
curl https://netlify-ip.html.zone/
或者直接访问https://netlify-ip.html.zone/
- 通过访问 Cloudflare 获取本机 IP 地理位置信息,
curl https://cloudflare-ip.html.zone/geo
或者直接访问https://cloudflare-ip.html.zone/geo - 通过访问 Vercel 获取本机 IP 地理位置信息,
curl https://vercel-ip.html.zone/geo
或者直接访问https://vercel-ip.html.zone/geo - 通过访问 Netlify 获取本机 IP 地理位置信息,
curl https://netlify-ip.html.zone/geo
或者直接访问https://netlify-ip.html.zone/geo
HTTP 响应头
x-client-ip
也是用户 IP 地址。
GEO 信息格式:
{"ip":"142.171.116.110","city":"Los Angeles","country":"US","flag":"🇺🇸","countryRegion":"California","region":"LAX","latitude":"34.05440","longitude":"-118.24410","asOrganization":"Multacom Corporation"}
# clone 此项目git clone https://github.com/ccbikai/ip-api.git# 进入项目目录cd ip-api# 安装依赖npm i## 部署到 Cloudflare Workersnpm run deploy:cloudflare## 部署到 Vercel Edgenpm run deploy:vercel## 部署到 Netlify Edgenpm run deploy:netlify
按照 Cloudflare/Vercel/Netlify 文档绑定域名即可。
Cloudflare 支持 IPv4 和 IPv6 访问,如果想只支持单栈,可以只解析 A/AAAA 记录到 Cloudflare 的泛拨 IP。
比如:https://cloudflare-ip-v4.html.zone/ 和http://cloudflare-ip-v6.html.zone/
- 提 Issue / Pull Request
- 联系https://twitter.com/ccbikai
About
利用 Cloudflare Workers / Vercel Edge / Netlify Edge 快速搭一个获取 IP 地址和地理位置信息的接口。
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published