Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 654
fancy Avatar asked Aug 29 '11 23:08

fancy


People also ask

How do I find the URL of a referrer?

To check the Referer in action go to Inspect Element -> Network check the request header for Referer like below. Referer header is highlighted. Supported Browsers: The browsers are compatible with HTTP header Referer are listed below: Google Chrome.

How do I find the URL of a node JS?

If you want to get the path info from request urlvar url_parts = url. parse(req. url); console. log(url_parts); console.

What is the referring URL?

The address of the webpage where a person clicked a link that sent them to your page. The referrer is the webpage that sends visitors to your site using a link. In other words, it's the webpage that a person was on right before they landed on your page.

How do I find the previous URL in node JS?

You have to store in session. app. get('/url1', function(req, res){ res. send('ok') req.


2 Answers

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

like image 192
Ross Avatar answered Sep 25 '22 01:09

Ross


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" 
like image 20
emboss Avatar answered Sep 27 '22 01:09

emboss