2
0
Files

15 lines
446 B
TypeScript
Raw Permalink Normal View History

2024-08-09 00:39:27 +02:00
import type { CreateInnerContextOptions } from "../../createContext";
type CountryCodeOptions = {
ctx: CreateInnerContextOptions;
};
export const countryCodeHandler = async ({ ctx }: CountryCodeOptions) => {
const { req } = ctx;
const countryCode: string | string[] = req?.headers?.["x-vercel-ip-country"] ?? "";
return { countryCode: Array.isArray(countryCode) ? countryCode[0] : countryCode };
};
export default countryCodeHandler;