I have two node.js applications. One backend api.domain and one frontend domain. I use express and passport. When trying to login in ... What I need in the api.domain app is the domain/url of the domain making the request.
But all my attempts failed:
In api.domain app:
const curIP = req.ip;
const curHostname = req.hostname;
console.log('IP: '+curIP);
console.log('Hostname: '+curHostname);
const curGetHost = req.get('host');
console.log('curGetHost: ' +curGetHost);
const curHost = req.host;
console.log(curHost);
var headerUserAgent = req.header('User-Agent');
console.log(headerUserAgent);
var origin = req.get('origin');
console.log(origin);
var headersOrigin = req.headers.origin;
console.log(headersOrigin);
var headersXForwarded = req.headers["x-forwarded-for"];
console.log(headersXForwarded);
var headersHost = req.headers["host"];
console.log(headersHost);
var remoteAddress = req.connection.remoteAddress;
console.log(remoteAddress);
It always outputs the domain of the api.domain app, not the domain app. How can I get the domain/url of the client trying to access my api.domain app?
Edit: On client side that's my request:
request.post({
headers: {
"Content-Type": "application/json",
"Referer": DOMAIN
},
url: URL_TARGET+"/v1/login",
body: JSON.stringify({
username: username,
password: password
})
}, ...