-
Notifications
You must be signed in to change notification settings - Fork 14.2k
fix: improve country code detection for phone input #28175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
b369e46
4f25ea0
f11d9be
f6df6cd
4d1b2ac
8cb2901
f2218ab
2518230
1f83108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,8 @@ type CountryCodeOptions = { | |
| export const countryCodeHandler = async ({ ctx }: CountryCodeOptions) => { | ||
| const { req } = ctx; | ||
|
|
||
| const countryCode: string | string[] = req?.headers?.["x-vercel-ip-country"] ?? ""; | ||
| const countryCode: string | string[] = | ||
| req?.headers?.["cf-ipcountry"] || req?.headers?.["x-vercel-ip-country"] || ""; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty-string fallback makes the timezone detection unreachable in The if (!data?.countryCode) {
return; // empty string is falsy → returns here
}
// …
} else {
const tzCountry = getCountryFromTimezone(); // ← never reached
🐛 Proposed fix const countryCode: string | string[] =
- req?.headers?.["cf-ipcountry"] || req?.headers?.["x-vercel-ip-country"] || "";
+ req?.headers?.["cf-ipcountry"] || req?.headers?.["x-vercel-ip-country"] || "Unknown";
🤖 Prompt for AI Agents |
||
| return { countryCode: Array.isArray(countryCode) ? countryCode[0] : countryCode }; | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.