A real-time geolocation detection application built with Next.js and EdgeOne Pages Functions. It automatically detects user location based on IP address and displays geographic information with a beautiful, responsive UI and dark mode support.
| Endpoint | Description |
|---|---|
GET / | Main page displaying geolocation info |
GET /geo | Returns geo data as JSON |
GET /zh | Returns geo data with Chinese translations |
GET /headers | Returns geo data via HTTP response headers |
| Header | Description |
|---|---|
x-geo-city | City name |
x-geo-country | Country name |
x-geo-region | Region/Province name |
x-client-ip | Client IP address |
x-isp | Internet Service Provider |
x-asn | Autonomous System Number |
x-latitude | Latitude coordinate |
x-longitude | Longitude coordinate |
x-tls-version | TLS encryption version |
x-country-code | ISO 3166-1 alpha-2 country code |
x-request-id | Unique request identifier |
git clone https://github.com/your-username/geolocation.git
cd geolocation
npm install
npm run dev
Open http://localhost:3000 to view the application.
npm run build
npm run start
├── app/
│ ├── page.tsx # Main page component
│ ├── layout.tsx # Root layout
│ └── globals.css # Global styles
├── components/
│ ├── AppleIcons.tsx # SVG icon components
│ └── ThemeToggle.tsx # Dark mode toggle component
├── functions/
│ ├── geo/index.ts # /geo endpoint
│ ├── zh/index.ts # /zh endpoint (Chinese)
│ └── headers/index.ts # /headers endpoint
├── lib/
│ ├── utils.ts # Utility functions
│ └── kv-storage.ts # KV storage operations wrapper
├── types/
│ └── kv.d.ts # TypeScript type definitions
└── package.json
The project integrates EdgeOne Pages KV storage for visit data recording:
Geolocation KV namespace in EdgeOne console and binding it to the projectFor detailed configuration instructions, please refer to KV_STORAGE_README.md
ISC