
What is the Geolocation Component?
The Geolocation component is an endpoint component that:- Responds to HTTP requests with geolocation data
- Provides continent, country, region, city, and IP information
- Runs at the edge for optimal performance
- Returns JSON responses with CORS support
- Requires no additional backend infrastructure
Getting Started
To integrate the Geolocation component into your Edgee project:- Open the Edgee console and navigate to your project’s Components.
- Select “Add a component” and choose
edgee/geolocation
from the list of available components. - Configure the endpoint path pattern (e.g.,
/apigeo
or/geolocation
). - Click Save to deploy the component.
API Response
The component returns a JSON response with the following structure:Usage Examples
JavaScript Fetch Request
cURL Request
Configuration
Path Pattern
Configure the URL path where the geolocation service will be available. For example:/apigeo
- Responds to requests atyourdomain.com/apigeo
/geolocation
- Responds to requests atyourdomain.com/geolocation
/location
- Responds to requests atyourdomain.com/location
Key Features
- Real-time Data: Provides current geolocation based on IP address
- Edge Performance: Runs at the edge for minimal latency
- CORS Support: Includes proper CORS headers for cross-origin requests
- No Cache: Returns fresh data with
no-store
cache control - JSON Format: Clean, structured JSON responses
- Serverless: No backend infrastructure required
Use Cases
The Geolocation component is perfect for:- Content Localization: Serve region-specific content based on user location
- Analytics: Track user geographic distribution
- Compliance: Determine applicable privacy regulations based on location
- Personalization: Customize user experience based on geographic data
- Security: Implement location-based access controls
Response Headers
The component automatically sets the following headers:Content-Type: application/json
Cache-Control: private, no-store
Access-Control-Allow-Origin: *
Performance
As an endpoint component running at the edge, the Geolocation service provides:- Sub-10ms response times in most cases
- Global availability through Edgee’s edge network
- Automatic scaling based on demand
- Zero maintenance - no servers to manage