#How to auto detect region?
21 messages · Page 1 of 1 (latest)
You could create a plugin or just add it as a custom service to your Medusa server. We have a plugin for IPStack, but you are free to use whatever service you wish to use. Since IP look ups are a paid service, I can’t see it become a core part of Medusa, but something that users can handle through plugins 🙂
Maxmind has a free DB that can be downloaded and used: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en
Develop applications using industry-leading IP intelligence and risk scoring.
But I guess another plugin is probably the best route
Can I try and contribute a maxmind plugin?
Here's the plugin i've created: https://github.com/g33kdev/medusa-plugin-ip-lookup-maxmind
Hey @half bear how can you "implement" this with the storefront so it autoselects the region? Do you have any examples? Thanks!
soo after installing this plugin, does the create cart api return the correct region?
I get: {"level":"error","message":"A region is required to create a cart","stack":[{"columnNumber":27,"fileName":"/app/medusa/node_modules/@medusajs/medusa/dis...
🧐 a region shouldn't be required according to this: https://docs.medusajs.com/api/store/#tag/Cart/operation/PostCart
Have you created regions and countries in your backend?
Ignore my previous error, it was due to a database missconfig. Right know everything works, the only issue is that is setting my IP to UK, but my IP is from Spain. I'm running the storefront in Vercel and the backend at home in a kubernetes cluster, both with SSL and no problems comunicating between them
I'm seeing a bunch of IPs in the logs but those are neither UK or my current IP
I looked up 172.68.134.37 and it looks like a cloudflare IP. Are you using cloudflare proxy?
I see that, at first I thought that, then I checked and it's on DNS-only mode
for your server (k8s cluster)?
I think it has something to do with: https://vercel.com/docs/concepts/edge-network/headers#x-forwarded-for
I'm adding x-vercel-forwarded-for to the plugin to verify if that solves it
both, vercel app and my k8s cluster are open, without cloudflare proxies
would you be okay DM'ing me your domain?
sure, which one? storefront or server?
server