Reputation: 29
I need to connect to a website.
I use http api from Node.js. I tried to connect directly and I did it. I connected with my default information.
But I want to define my referer and browser information, also my cookies. How can I do that?
Upvotes: 1
Views: 7241
Reputation: 130
You need to define the headers in the options variable.
var http = require('http');
var options = {
hostname: 'www.google.com',
path: '/upload',
headers: {
'User-Agent': 'whatever',
'Referer': 'http://localhost/',
'Cookie': 'COOKIE_NAME=value; COOKIE_NAME=value'
}
};
http.get(options, callback);
Upvotes: 4