Files
calendar/packages/trpc/server/routers/publicViewer/countryCode.handler.ts
T
b6279f4128 fix: country code [Testing] (#12807)
* fix: country code

* chore

* chore: only test cloudflare

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2023-12-19 08:01:08 +00:00

17 lines
575 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { CreateInnerContextOptions } from "../../createContext";
type CountryCodeOptions = {
ctx: CreateInnerContextOptions;
};
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"] ?? "";
return { countryCode: Array.isArray(countryCode) ? countryCode[0] : countryCode };
};
export default countryCodeHandler;