[Referer](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36) is an http optional header in a request contains domain or a page URL making request. some times
Referer is also called
referrer as old browsers still reference this. We can use any one of this.
Suppose In a website1.com, You have a link pointing to different website2.com, and website2 contains Referer as website.com
In request header, You will see the following value
if you directly access the website directly,
referrer value is undefined.
How to find the referer page url in nodeJS application
In Nodejs, Express library http headers are retrieved using request object.
if you are using express version less than 4.x
You can directly call below method
console.log(req.headers.referer) // website1.com
In expression 4.x version
you can get using request.get method
Referrer is an case insensitive header
console.log(req.get('Referrer')) // website1.com
This method checks for for Referer and Referrer header in a request
You learned how to retrieved return url in node express application. This header value is controlled by client, This can be modified and changed to different value, So it is not better to use logic based on value. However logging and analytics purpose we can consider