I have a question about the nextjs page middleware, see here, according to the documentation the request object should contain geo, IP, ua, cookies and nexturl properties.
So all I am trying to do is get the users location through page middleware like this:
import { NextRequest, NextResponse } from 'next/server';
export async function middleware(req) {
const { nextUrl, geo } = req;
console.log(geo) //=> always empty {}
const country = geo.country || 'US'
nextUrl.searchParams.set('locale', country);
return NextResponse.rewrite(nextUrl);
}
But when I run my project locally the geolocation is an empty object, why?
Will all hosting providers send geolocation data, or does it depend on the provider?