How can I solve geo-localisation using NextJS rewrites fallback #65840
Unanswered
Maxwell2022
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
We are adopting NextJS slowly and therefor we are using NextJS builtin rewrite rules to fallback request to our older application. This is working great even tho it has to trigger a middleware request to every client requests 🤑
Our old application is hosted on AWS and is using CloudFront to detect user geographic regions.
The problem we currently have is that the request cloudfront is receiving is from the Vercel edge network and therefor is not identifying the region of the user, but of the edge node. It's not a big problem in general, however Vercel does not have nodes in all countries and so it sometime detect US instead of Canada (for example).
I've investigated a little bit more and I don't think CloudFront can use the
X-Forwarded-For
headers that exposes the user real ip. I don't think CF is meant to be working behind a proxy.I was thinking that maybe I could use the Vercel geolocation header (
x-vercel-ip-country
) but it seems this is not injected in the request from the fallback rule.Does anyone think of a simple solution that does not involve us building a custom middleware in NextJS?
Is there any reason why the Vercel geo headers are not send in the fallback request?
Thank you,
Maxime
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions