How to set fake Referer by using Express - Node JS?

Alex_black

Newbie
Joined
Jan 15, 2019
Messages
14
Reaction score
3
In my case, when clients reach my website, they will be redirected to another website with 301 redirect. In server-side, I customize the referrer field in HTTP header by using Express JS as code below.

Code:
var express = require('express');
var app = express();
 
app.listen(3000);
 
app.get('/', function(req, res) { 
    res.set('Referer', 'www.google.com');
    res.redirect(301, 'www.whatismyreferer.com'); 
});

However, the referer isn't set as I wish. Please, anybody helps me.
 
that is not going to work, you cannot manipulate the referer from a server

your code sets a referer header in the http response
the browser will read the response, see a 301 redirect and make a new request to
whatismyreferer.com with the correct referer header
 
Back
Top