Files
wiki/netlify/edge-functions/geo.ts
Wayne Sutton 4a912fd345 docs: add visitor map configuration to README and update docs.md
- Added visitor map section to README.md after GitHub Contributions Graph
- Updated visitor map description in content/pages/docs.md with privacy details
- Documents configuration options in src/config/siteConfig.ts
- Explains Netlify geo detection and theme-aware colors
2025-12-21 15:58:43 -08:00

33 lines
873 B
TypeScript

import type { Context } from "@netlify/edge-functions";
// Returns the user's geo location from Netlify's automatic geo headers
// Privacy friendly: only returns city/country/coordinates, no IP address stored
export default async function handler(
_request: Request,
context: Context,
): Promise<Response> {
// Netlify provides geo data automatically via context.geo
const geo = context.geo;
const data = {
city: geo?.city || null,
country: geo?.country?.code || null,
countryName: geo?.country?.name || null,
latitude: geo?.latitude || null,
longitude: geo?.longitude || null,
};
return new Response(JSON.stringify(data), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "private, max-age=3600",
"Access-Control-Allow-Origin": "*",
},
});
}
export const config = {
path: "/api/geo",
};