Closed danjames68 closed 2 years ago
Hey @danjames68 , the way Cloudflare work is they inject those headers in the response. You can easily retrieve these via Grav already, through they URI::getAllHeaders
method. For example in any of your twig files you can do:
Country: {{ grav.uri.getAllHeaders['Cf-Ipcountry'] }}
IP: {{ grav.uri.getAllHeaders['Cf-Connecting-Ip']) }}
Hope this helps!
Hi @w00fz, thanks so much - it's obvious now you've told me! I had got as far as finding them in the header but I'd forgotten about grav.uri.getAllHeaders
- that's just made my life so much easier! As a (very) part-time coder I can get stuck on quite simple problems.
It’s all good, we all love simple solutions!
I need to use the Geolocation data, Cloudflare says it needs pulling from CF-IPCountry HTTP Header - I had hoped to find some notes in the Cloudflare plugin to shortcut this process.