Edge Function: Cannot get geo informations since v12
See original GitHub issueWhat 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: https://github.com/vercel/examples/issues/24 https://github.com/vercel/examples/issues/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)
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Restrictions on edge functions - Amazon CloudFront
The following topics describe the restrictions that apply to CloudFront Functions and Lambda@Edge. Some restrictions apply to all edge functions, ...
Read more >Next.js v12 - Building a Geolocation Country Block App w
... power of Vercel Edge Functions Building a Geolocation Country Block App and how them allow us to ... Your browser can't play...
Read more >Vercel Edge Functions with Next.js - Ahmad Awais
Vercel's Edge Functions to be used with Next.js (v12) announced today at ... getting geolocation from an IP Address, and user-agent info.
Read more >Edge Functions – Vercel Docs
Edge Functions are defined in JavaScript or TypeScript files in your codebase. You can specify a Function's region by exporting a config object...
Read more >[aws-lambda] CurrentVersion not available for imported ...
General Issue The Question I'm only able to get .currentVersion on the new lambda function, but not on the imported one.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
geo
won’t work locally because your address is127.0.0.1
(ref). You’ll want to try spinning it up on an online dev env!This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.