-
Notifications
You must be signed in to change notification settings - Fork 87
Geo data missing in middleware #2880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You are correct that this functionality was removed from Next.js in v15.0.0 Due to how There is still a way to access the same Example:
Hope that helps clear things up! |
@mrstork, thanks for confirming the behaviour. I had completely forgotten that the global In any case, I have used the below code which works really well, especially for local testing outside of the Netlify CLI by hooking into the type Geo = Exclude<(typeof Netlify)['context'], null>['geo']
let geo: Geo | undefined
try {
geo = Netlify.context?.geo
} catch {}
const country =
geo?.country?.code ??
request.headers.get('x-nf-country') |
After upgrading to Next.js v15, I noticed the
geo
property onNextRequest
was missing, which was fine because Vercel removed it from the interface.However, I assume the object should still be injected into the request object via the edge function context. This assumption is based on:
opennextjs-netlify/edge-runtime/lib/next-request.ts
Lines 111 to 118 in 17a1202
It returns
null
when accessing thegeo
property, like Next.js v14. That makes me believe that something within Next.js was removed to support this, but given that this plugin should reinstate it, I'm perplexed about the intended use.Any thoughts would be much appreciated.
The text was updated successfully, but these errors were encountered: