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

JavascriptHttpnode.jsExpress

Javascript Problem Overview


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!

Javascript Solutions


Solution 1 - Javascript

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

Solution 2 - Javascript

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.headers.referer;
// => "http://google.com"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfancyView Question on Stackoverflow
Solution 1 - JavascriptRossView Answer on Stackoverflow
Solution 2 - JavascriptembossView Answer on Stackoverflow