How do I find the a referring sites URL in node?


Question

How do I find the a referring sites URL in node?

I'm using express, would I find this in the headers on connect or something?

Thanks!

1
34
8/29/2011 11:44:44 PM

Accepted Answer

If you mean how do you get it when running an express server, then it's done using the header method on your request:

req.header('Referer');
// => "http://google.com"
52
8/29/2011 11:49:54 PM

In express 4.x:

req.get('Referrer')

This will also check both spellings of referrer so you do not have to do:

 req.headers.referrer || req.headers.referer

Here is the documentation


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon