Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get "HTTP_REFERER" with NodeJS?

A way to get HTTP_REFERER , We can use document.referrer in browser side javascript . But how can we get it in NodeJS ?

like image 238
Enkows Avatar asked May 14 '12 08:05

Enkows


People also ask

How do I get referer from HTTP request in node JS?

1 Answer. Show activity on this post. var http = require('http'); server = http. createServer(function(req, res){ ... }

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.

How do I get referer headers?

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.

What is $_ server [' HTTP_REFERER ']?

$_SERVER['HTTP_HOST'] Returns the Host header from the current request. $_SERVER['HTTP_REFERER'] Returns the complete URL of the current page (not reliable because not all user-agents support it)


1 Answers

You can get it by...

req.headers.referer 

in...

var http = require('http'); server = http.createServer(function(req, res){ ... } 
like image 59
Phatsin.lk Avatar answered Sep 19 '22 23:09

Phatsin.lk