exports.checkReq = functions.region('asia-east2').https.onCall(async (data, { rawRequest }) => {
try {
const ip = rawRequest.headers['x-forwarded-for'] || rawRequest.connection.remoteAddress
const response = await axios.get(
`http://api.ipstack.com/${ip}?access_key=${IPSTACK_API_KEY}`
)
// console.log( rawRequest,ip, response)
return {
ip,
city: response.data.city,
success: 'yes'
}
} catch (error) {
throw new functions.https.HttpsError(error)
}
})
Created
October 26, 2019 13:06
-
-
Save isaumya/a1c7285df97417f6d47b1954cab97ff9 to your computer and use it in GitHub Desktop.
Get Cleint IP & IP Details with Firebase Cloud Callable Function
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment