chore: added a fallback for country code (#13171)

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
Udit Takkar
2024-01-15 09:51:16 +00:00
committed by GitHub
co-authored by Peer Richelsen
parent 0a921c2929
commit b1bf94aa58
@@ -7,9 +7,8 @@ type CountryCodeOptions = {
export const countryCodeHandler = async ({ ctx }: CountryCodeOptions) => {
const { req } = ctx;
// const countryCode: string | string[] =
// req?.headers?.["cf-ipcountry"] ?? req?.headers?.["x-vercel-ip-country"] ?? "";
const countryCode: string | string[] = req?.headers?.["cf-ipcountry"] ?? "";
const countryCode: string | string[] =
req?.headers?.["cf-ipcountry"] ?? req?.headers?.["x-vercel-ip-country"] ?? "";
return { countryCode: Array.isArray(countryCode) ? countryCode[0] : countryCode };
};