I am trying to figure out what the best way would be to pass geoIP info of users to client-side javascript. I have configured nginx for this and am able to send the info to my node + express server.
I don't know what the next step is. From googling around i can see the headers I am trying to send can't directly be read by js on client-side.
This is what I have --
Nodejs--
router.get('/', function(req, res, next) {
res.setHeader("geoip_country_code", req.headers.geoip_country_code);
res.setHeader("geoip_city", req.headers.geoip_city);
res.render('index', { title: 'bla' });
console.log(req.headers);
});
Nginx --
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
proxy_set_header GEOIP_CITY $geoip_city;
proxy_set_header GEOIP_LATITUDE $geoip_latitude;
proxy_set_header GEOIP_LONGITUDE $geoip_longitude;
proxy_pass http://app:3000;
}