Showing a consent banner to every visitor annoys people outside the EU, and hiding it from everyone is a compliance risk. A cheap middle path: look up the visitor's IP once, cache the answer, and show the banner only when the address is in an EU country.
The IP lookup endpoint returns an is_eu boolean, so there is no country list to maintain. Here is the real response for a German address (tested live):
{ "asn" : 60729 , "continent_code" : "EU" , "country" : "Germany" , "country_code" : "DE" , "ip" : "185.220.101.1" , "is_eu" : true , "is_global" : true , "is_private" : false , "organization" : "Stiftung Erneuerbare Freiheit" , "version" : 4 }
Enter fullscreen mode
Exit fullscreen mode
For 8.8.8.8 the same call gives "country_code": "US" and "is_eu": false .…