0

I only get the from which domain the request comes but I want to get the domain name with query parameters. For example the main domain name with query parameters htpps://abc.com?userId=1&campaiginId=2

From above domain I request to https://external.com

<img src="https://external.com"></img>

Now from which domain request comes with query parameters I want like below this:

htpps://abc.com?userId=1&campaiginId=2

If I use req.get('origin') I only get the domain name but I need with query parameters too.

Thanks

// Here is my code

req.get('/route', function (req, res) { var origin = req.get('origin'); console.log(origin) });

// Now from which domain request comes with query parameters I want like below this:

// htpps://abc.com?userId=1&campaiginId=2

Md Saif Uddin
  • 179
  • 2
  • 8

1 Answers1

0

To get the URL with its query params

const origin = req.headers.host;
console.log("Origin: ", origin)
const restUrl = req.originalUrl;
console.log("Rest part of the URL: ", restUrl);

Hope this help

Imran Azim
  • 154
  • 1
  • 8