I need to identify my visitor’s country. Since App Platform is behind Cloudflare, I was expecting to receive the header CF-IPCountry in my backend, but it seems that is not the case. Is there a way to turn that on?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
From what I can tell, App Platform does not seem to forward Cloudflare-specific headers like CF-IPCountry to your backend. Even though App Platform runs behind Cloudflare, there is another routing layer in between, and those CF headers do not appear to be exposed.
Based on the docs, the headers you can reliably expect are the standard forwarded ones, like X-Forwarded-For and X-Forwarded-Proto. You can see the full list here: https://docs.digitalocean.com/products/functions/reference/http-headers/
There is no mention of CF-IPCountry being available, which suggests it is not currently supported. If country detection is required, you would likely need to infer it from the client IP using X-Forwarded-For and your own geo lookup.
I am not aware of a way to enable CF-IPCountry at the moment. If this would be useful, it might be worth suggesting it as an idea here: https://ideas.digitalocean.com/
Hi,
When you deploy on DigitalOcean App Platform, your app sits behind DigitalOcean’s own edge, even if you use Cloudflare in front. App Platform does not forward Cloudflare-specific headers like CF-IPCountry to your backend, and there’s currently no setting to enable that.
If you need country detection, the practical workaround is to take the client IP from X-Forwarded-For and do your own GeoIP lookup in the app (or via an external service).
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.