Skip to content

Commit

Permalink
test geo data from edge function
Browse files Browse the repository at this point in the history
  • Loading branch information
viet nguyen committed Jan 23, 2024
1 parent 38a4c37 commit 76fa861
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@turf/bbox": "^6.5.0",
"@turf/line-to-polygon": "^6.5.0",
"@udecode/zustood": "^1.1.3",
"@vercel/edge": "^1.1.1",
"auth0": "^2.42.0",
"awesome-debounce-promise": "^2.1.0",
"aws-sdk": "^2.1265.0",
Expand Down
9 changes: 5 additions & 4 deletions src/app/api/geo/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { NextRequest, NextResponse } from 'next/server'
import { geolocation } from '@vercel/edge'

export const dynamic = 'force-dynamic'
export const fetchCache = 'force-no-store'
export const runtime = 'edge'

/**
* Endpoint: `/api/geo`
*/
export async function GET (request: NextRequest): Promise<any> {
const longitude = request.geo?.longitude
const latitude = request.geo?.latitude
const geo = geolocation(request)
const longitude = geo?.longitude
const latitude = geo?.latitude
if (longitude != null && latitude != null) {
return NextResponse.json({ longitude, latitude }, { status: 200 })
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2923,6 +2923,11 @@
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==

"@vercel/edge@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@vercel/edge/-/edge-1.1.1.tgz#9b2fc0081dfe95db8b4c3598275721b1ad85e43f"
integrity sha512-NtKiIbn9Cq6HWGy+qRudz28mz5nxfOJWls5Pnckjw1yCfSX8rhXdvY/il3Sy3Zd5n/sKCM2h7VSCCpJF/oaDrQ==

"@wry/context@^0.7.0", "@wry/context@^0.7.3":
version "0.7.3"
resolved "https://registry.yarnpkg.com/@wry/context/-/context-0.7.3.tgz#240f6dfd4db5ef54f81f6597f6714e58d4f476a1"
Expand Down

0 comments on commit 76fa861

Please sign in to comment.