A way to get HTTP_REFERER
, We can use document.referrer
in browser side javascript .
But how can we get it in NodeJS ?
Asked
Active
Viewed 6.4k times
71

Enkows
- 715
- 1
- 5
- 7
-
1possible duplicate of [Getting HTTP headers with node.js](http://stackoverflow.com/questions/5922842/getting-http-headers-with-node-js) – Quentin May 14 '12 at 08:44
-
2Take a look to req.headers / req.header('Referer') – Maxim Krizhanovsky May 14 '12 at 08:53
-
1Possible duplicate of [How do I find the a referring sites URL in node?](http://stackoverflow.com/questions/7237262/how-do-i-find-the-a-referring-sites-url-in-node) – Slava Fomin II May 03 '16 at 22:04
1 Answers
112
You can get it by...
req.headers.referer
in...
var http = require('http');
server = http.createServer(function(req, res){
...
}

posit labs
- 8,951
- 4
- 36
- 66

Phatsin.lk
- 1,306
- 1
- 11
- 8
-
-
1
-
I would add that some browsers send referer (like chrome) and some referrer (like Safari on OSx) – in need of help Feb 22 '17 at 09:01
-
Consider https://stackoverflow.com/a/28238737/205832 instead if you use Express 4.x. – Peter Bengtsson Jun 05 '17 at 12:53
-
1This seems to no longer be the case ... where did it move to? There's no .headers on the IncomingMessage anywhere? – Oct 01 '21 at 15:14