Skip to content

Instantly share code, notes, and snippets.

@eldarc
Last active July 7, 2018 13:38
Show Gist options
  • Select an option

  • Save eldarc/2271fa18e00a6b1a41c4d6524c44d0b8 to your computer and use it in GitHub Desktop.

Select an option

Save eldarc/2271fa18e00a6b1a41c4d6524c44d0b8 to your computer and use it in GitHub Desktop.
const cors = require('cors')
function _geolocation(req, res) {
const data = {
country: req.headers["x-appengine-country"],
region: req.headers["x-appengine-region"],
city: req.headers["x-appengine-city"],
cityLatLong: req.headers["x-appengine-citylatlong"],
userIP: req.headers["x-appengine-user-ip"]
}
res.json(data)
};
exports.geolocation = (req, res) => {
const corsHandler = cors({ origin: true })
return corsHandler(req, res, function() {
return _geolocation(req, res);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment