-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.
Description
What version of Next.js are you using?
12.0.2
What version of Node.js are you using?
16.6.0
What browser are you using?
Brave, Safari
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
By logging the request
object, we can confirm that the geo
and ip
are undefined
.
The DEPLOYED example of the geolocation usage still works correctly, but the other new examples deployed by clicking the "Deploy" button on the README page cannot work correctly. https://github.com/vercel/examples/tree/main/edge-functions/geolocation
There were two issues opened for this bug:
vercel/examples#24
vercel/examples#34
Expected Behavior
It should be possible to get the geolocation data from request
object like in the example.
To Reproduce
import { NextRequest, NextResponse } from 'next/server';
export async function middleware(req: NextRequest) {
console.log(req);
const { geo } = req;
const { nextUrl: url, geo } = req
const country = geo.country || 'US'
url.searchParams.set('country', country)
return NextResponse.rewrite(url)
}
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.