Geolocation context

Hello, Netlify team!

I’m checking your example with geolocation object in Context: Geolocation | Edge Functions on Netlify

Could you help me: where do you take geo info for user? Is it IP address or specific headers?

Thank you in advance

:wave: @alisakova ,

For Edge Functions, we look up the geo info from the IP in MaxMind’s geoip database which you can test out here: GeoIP2 Databases Demo | MaxMind .

Hope this helps!

Hi @audrey, I see that the MaxMind resource also includes Postal Code, but it appears to be missing in context.geo. Why is Postal Code not currently included, and can it be?

I’ll ask the devs if it’s possible to add postal code as well.

1 Like

Hello @hrishikesh - just checking in to see if there’s been any feedback regarding inclusion of postal code in context.geo.

Not yet. This is not something that could happen soon as it falls back in priority against various other important things.

Hey @dreysolano, thanks for your feature request.

We’ve now rolled out support for postal codes in the Geo object. The property is called postalCode and can be used from functions and edge functions.

I hope you’ll find this useful.

1 Like

@marcus this is great! Despite being a relatively small change, this will greatly improve our geolocation flow. Thank you!

1 Like

Hello @marcus,

Following up on this new Geo.postalCode feature: I noticed recently that the Geo object appears to still be missing postalCode when running locally via netlify dev. The same app does include postalCode for the same location once it’s been deployed beyond a local machine.

Is an update to netlify-cli required to ensure postalCode is included in the Geo object locally as well?

The CLI fetches geolocation here: cli/src/lib/geo-location.ts at main · netlify/cli, which basically makes a request to this site: netlifind.netlify.app and returns the data that is returned there. However, the data is cached: cli/src/lib/geo-location.ts at main · netlify/cli, so maybe you’re seeing the data that we stored the first time when postCode was not being returned. Have you tried deleting .netlify folders from your device (you might have to re-login and re-link your sites).