search
Geolocation Headers in Launch
Launch automatically includes geolocation headers in every incoming request. You can use these headers in Edge Functions, Cloud Functions, or backend APIs to personalize content, analyze traffic, or apply region-specific logic.
Available Headers
All requests on Launch include the following geolocation headers:
Location Header Name | Description | Example |
---|---|---|
Visitor-IP-Country | The 2-letter country code of the IP address | US |
Visitor-IP-Region | The ISO 3166-2 name for the first-level region associated with the IP | Oregon |
Visitor-IP-City | The city name associated with the IP address | The Dalles |
Note: Launch’s Edge infrastructure automatically injects these headers. They are available across all Contentstack regions.
How to Access Geolocation Headers
Geolocation headers are included in each incoming request and can be accessed like any other HTTP headers using your runtime's API. See the following examples:
Edge Function Example (JavaScript)
// Edge Function export default function handler(request, context) { const country = request.headers.get('visitor-ip-country'); const region = request.headers.get('visitor-ip-region'); const city = request.headers.get('visitor-ip-city'); const parsedUrl = new URL(request.url); if (parsedUrl.pathname === '/appliances') { return new Response(JSON.stringify({ location: `${city}, ${region}, ${country}`, timestamp: new Date().toISOString(), }), { headers: { 'Content-Type': 'application/json' } }); } return fetch(request); }
Cloud Function Example
// functions/hello.js export default function handler(request, response) { const country = request.headers['visitor-ip-country']; const region = request.headers['visitor-ip-region']; const city = request.headers['visitor-ip-city']; response.status(200).json({ location: `${city}, ${region}, ${country}`, method: request.method, }); }
Next.js API Route Example
// pages/api/geo.js export default function handler(req, res) { const country = req.headers['visitor-ip-country']; const region = req.headers['visitor-ip-region']; const city = req.headers['visitor-ip-city']; res.status(200).json({ location: `${city}, ${region}, ${country}`, timestamp: new Date().toISOString(), }); }
Troubleshooting
If a header value appears empty or inaccurate, it may be due to one of the following uncommon scenarios:
- Privacy tools: The visitor is using a VPN, proxy, or privacy-focused browser.
- New IP ranges: The IP address is recently allocated and not yet listed in global geolocation databases.
More articles in "Launch Features"
Create a Project using GitHub
Learn morearrow_forward
Create a Project Using Bitbucket Cloud
Learn morearrow_forward
Create a Project using File Upload
Learn morearrow_forward
Deployments
Learn morearrow_forward
Environments
Learn morearrow_forward
Environment Variables
Learn morearrow_forward
Custom Domain
Learn morearrow_forward
Deploy Hooks
Learn morearrow_forward
Cloud Functions
Learn morearrow_forward
Password Protection for Environments
Learn morearrow_forward
Edge URL Redirects
Learn morearrow_forward
Edge URL Rewrites
Learn morearrow_forward
Revalidate CDN Cache
Learn morearrow_forward
Build Image
Learn morearrow_forward
Log Targets
Learn morearrow_forward
Edge Functions
Learn morearrow_forward
Supported Node.js Versions
Learn morearrow_forward
Supported Package Managers
Learn morearrow_forward
Users
Learn morearrow_forward
Real-Time User Event Tracking with Data and Insights (Lytics) in Contentstack Launch
Learn morearrow_forward
Cache Priming
Learn morearrow_forward
Traffic Encryption
Learn morearrow_forward