feat: get country code from ip geolocation (#6880)

* feat: get coutnry code from ip geolocation

Signed-off-by: Udit Takkar <[email protected]>

* fix: create new api route for fetching code

Signed-off-by: Udit Takkar <[email protected]>

* chore: replace city with country

Signed-off-by: Udit Takkar <[email protected]>

* refactor: create hook for country

Signed-off-by: Udit Takkar <[email protected]>

---------

Signed-off-by: Udit Takkar <[email protected]>
This commit is contained in:
Udit Takkar authored and GitHub committed 2023-02-25 12:15:05 -07:00
1 parent 8c63b42cec
commit c20835a4c8
2 files changed
+40

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import type { NextRequest } from "next/server";
export const config = {
runtime: "experimental-edge",
};
export default async function handler(req: NextRequest) {
const countryCode = req.headers.get("x-vercel-ip-country") ?? "";
return new Response(
JSON.stringify({
countryCode,
}),
{
status: 200,
headers: {
"content-type": "application/json",
},
}
);
}