I'm using express.js and I need to know the domain which is originating the call. This is the simple code
app.get(
'/verify_license_key.json',
function( req, res ) {
// do something
How do I get the domain from the req
or the res
object?
I mean I need to know if the API was called by somesite.example
or someothersite.example
.
I tried doing a console.dir of both req
and res
but I got no idea from there, also read the documentation but it gave me no help.
req.host
orreq.get('host')
expresses docsreq.headers["x-forwarded-for"] || req.connection.remoteAddress
x-forwarded-for would cover your bases behind a proxy, load balancer...