-
Notifications
You must be signed in to change notification settings - Fork 368
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
fix(dev): allow passing mock country for geo-based redirects #5093
fix(dev): allow passing mock country for geo-based redirects #5093
Conversation
📊 Benchmark resultsComparing with 138681d Package size: 223 MB(no change)
Legend
|
src/utils/rules-proxy.js
Outdated
const getCountry = function (geoCountry) { | ||
return geoCountry || 'us' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed w/ @kitop on Slack. Not sure why this fallback to 'us'
exists but we decided to preserve it for backwards compatibility.
src/utils/rules-proxy.js
Outdated
@@ -80,7 +80,7 @@ const createRewriter = async function ({ configPath, distDir, jwtRoleClaim, jwtS | |||
const cookieValues = cookie.parse(req.headers.cookie || '') | |||
const headers = { | |||
'x-language': cookieValues.nf_lang || getLanguage(req.headers), | |||
'x-country': cookieValues.nf_country || getCountry(), | |||
'x-country': cookieValues.nf_country || getCountry(geoCountry), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just simplify that instead of having a function for that?
'x-country': cookieValues.nf_country || getCountry(geoCountry), | |
'x-country': cookieValues.nf_country || geoCountry || 'us', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasholzer Made the suggested change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution but can we keep it simple? I think we don't need a function for that one
f36418f
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes #5051
The
dev
command doesn't allow a way for users to pass any flags to mock the current country to test out country based redirects which hinders local dev workflow.Also, the "country" value used for redirects just defaults to
US
with no way to over-ride it which causes all requests for a route to be redirected in case a redirect rule with country value asUS
exists & prevents users from checking how the page without redirect looks.This PR uses the value from pre-existing
country
flag for redirects. This allows the user to pass country values easily through the command line flag & test out country-based redirects properly.For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)
🦆