Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Localhost and NextJs custom middleware

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!