{"id":29640507,"url":"https://github.com/fernandodilland/cloudflare-workers-where-i-am-api","last_synced_at":"2026-05-04T22:36:31.759Z","repository":{"id":304289320,"uuid":"1018364274","full_name":"fernandodilland/cloudflare-workers-where-i-am-api","owner":"fernandodilland","description":"API developed with Rust to be deployed in Cloudflare Workers to query the requester's region.","archived":false,"fork":false,"pushed_at":"2025-07-12T06:27:37.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-12T07:03:28.543Z","etag":null,"topics":["api","api-rest","cloudflare","cloudflare-workers","rust","rust-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fernandodilland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-12T05:30:31.000Z","updated_at":"2025-07-12T06:27:40.000Z","dependencies_parsed_at":"2025-07-12T07:13:53.928Z","dependency_job_id":null,"html_url":"https://github.com/fernandodilland/cloudflare-workers-where-i-am-api","commit_stats":null,"previous_names":["fernandodilland/cloudflare-workers-where-i-am-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/fernandodilland/cloudflare-workers-where-i-am-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandodilland%2Fcloudflare-workers-where-i-am-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandodilland%2Fcloudflare-workers-where-i-am-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandodilland%2Fcloudflare-workers-where-i-am-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandodilland%2Fcloudflare-workers-where-i-am-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernandodilland","download_url":"https://codeload.github.com/fernandodilland/cloudflare-workers-where-i-am-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandodilland%2Fcloudflare-workers-where-i-am-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266379212,"owners_count":23920157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-rest","cloudflare","cloudflare-workers","rust","rust-api"],"created_at":"2025-07-21T21:02:06.966Z","updated_at":"2026-05-04T22:36:26.736Z","avatar_url":"https://github.com/fernandodilland.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloudflare Workers Rust - Where Am I API\n\n🦀 A high-performance Rust-based Cloudflare Worker that provides geolocation information using Cloudflare's edge headers.\n\n[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/fernandodilland/cloudflare-workers-where-i-am-api)\n\n## Features\n\n- **⚡ High Performance**: Built with Rust for maximum speed\n- **⚖️ Lightweight**: Compiled to WebAssembly for minimal size\n- **🌐 CORS Ready**: Configurable cross-origin request support\n- **📍 Geolocation**: Extracts location data from Cloudflare headers\n- **🔒 Secure**: Production-ready with configurable CORS origins\n- **🚀 Easy Deploy**: Multiple deployment options available\n\n## Quick Start\n\n### API Endpoint\n\n**`GET /`** - Returns geolocation information based on your IP address\n\n```bash\ncurl https://your-worker-name.your-subdomain.workers.dev/\n```\n\n**Response:**\n```json\n{\n  \"CF-IPCountry\": \"US\",\n  \"CF-IPCity\": \"San Francisco\",\n  \"CF-IPContinent\": \"NA\",\n  \"CF-IPLongitude\": \"-122.39420\",\n  \"CF-IPLatitude\": \"37.77490\",\n  \"CF-Region\": \"California\",\n  \"CF-Region-Code\": \"CA\",\n  \"CF-Metro-Code\": \"807\",\n  \"CF-Postal-Code\": \"94107\",\n  \"CF-Timezone\": \"America/Los_Angeles\"\n}\n```\n\n### Testing with Postman\n\n1. Create a **GET** request to your Worker URL\n2. **Optional Headers** for CORS testing:\n   - `Origin`: `https://yourdomain.com`\n   - `Content-Type`: `application/json`\n3. **Expected Response**: `200 OK` with geolocation JSON data\n\n## Deployment\n\n### 🚀 Quick Deploy (Recommended)\n\n**Option 1: Automated Scripts**\n```bash\n# Windows\n./deploy.bat\n\n# Linux/Mac\n./deploy.sh\n```\n\n**Option 2: Manual Commands**\n```bash\ncargo install worker-build\nworker-build --release\nwrangler deploy\n```\n\n### 🤖 GitHub Actions (Production)\n\nAutomated deployment on every push to `main`:\n\n1. **Repository Settings** → **Secrets and Variables** → **Actions**\n2. **Add Secret**: `CLOUDFLARE_API_TOKEN` ([Get token here](https://dash.cloudflare.com/profile/api-tokens))\n3. **Push to main** → Auto-deploy triggered\n\n### � Troubleshooting\n\n| Error | Solution |\n|-------|----------|\n| `cargo: not found` | Use deployment scripts or GitHub Actions |\n| `worker-build: not found` | Run `cargo install worker-build` |\n| `wrangler: not found` | Run `npm install -g @cloudflare/wrangler` |\n\n## Configuration\n\n### Environment Variables\n\nConfigure CORS origins for enhanced security:\n\n```toml\n# wrangler.toml\n[vars]\nCORS_ALLOWED_ORIGINS = \"https://myapp.com,https://api.myapp.com\"\n```\n\n**Security Best Practices:**\n- ❌ Never use `*` in production\n- ✅ Use HTTPS-only origins\n- ✅ Specify exact domains\n- ✅ Regular security audits\n\n### Custom Domain Setup\n\nFor full geolocation header support, use a custom domain:\n\n1. **DNS Configuration**:\n   ```\n   Type: A\n   Name: api\n   Content: 192.0.2.1\n   Proxy: ✅ Enabled\n   ```\n\n2. **Cloudflare Dashboard**:\n   - **Workers** → **Your Worker** → **Settings** → **Domains \u0026 Routes**\n   - **Add Route**: `api.yourdomain.com/*`\n\n3. **Enable Geolocation Headers**:\n   - **Dashboard** → **Your Domain** → **Rules** → **Settings**\n   - **Enable**: \"Add visitor location headers\"\n\n## Development\n\n### Prerequisites\n\n- [Rust](https://rustup.rs/) (latest stable)\n- [Node.js](https://nodejs.org/) and npm\n- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/)\n\n### Local Development\n\n```bash\n# Install dependencies\nnpm install -g @cloudflare/wrangler\ncargo install worker-build\n\n# Run locally\nwrangler dev\n```\n\n## Available Headers\n\nThe API extracts these Cloudflare geolocation headers:\n\n| Header | Description |\n|--------|-------------|\n| `CF-IPCountry` | Country code (US, CA, etc.) |\n| `CF-IPCity` | City name |\n| `CF-IPContinent` | Continent code (NA, EU, etc.) |\n| `CF-IPLongitude` | Longitude coordinate |\n| `CF-IPLatitude` | Latitude coordinate |\n| `CF-Region` | Region/state name |\n| `CF-Region-Code` | Region/state code |\n| `CF-Metro-Code` | Metro area code |\n| `CF-Postal-Code` | Postal/ZIP code |\n| `CF-Timezone` | Timezone identifier |\n\n**Note**: Full header availability requires a custom domain with visitor location headers enabled.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandodilland%2Fcloudflare-workers-where-i-am-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernandodilland%2Fcloudflare-workers-where-i-am-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandodilland%2Fcloudflare-workers-where-i-am-api/lists"}