Console Logs for all sites

Through the console, is there a way to get the logs of the individual sites opened? I can only receive the ones through the Koyeb start-up.


If I open new sites, the logs don’t change. No matter where I am, it always returns Koyeb’s data, not the user’s.

Background:

I’m using the IP, and other information to make the page more responsive, and better fitting to the user. This is a low traffic website, and all users have given consent to being tracked.

Hey!

Your Koyeb Instance sits behind our load balancer stack, so what you see is their IP. You can use the x-forwarded-for header to find the “real” IP address of the client connecting to your app: X-Forwarded-For - HTTP | MDN.

Let me know if you need more help

Could you please give me a code example?
Mine is:

//IP Finding
function json(url) {
  return fetch(url).then(res => res.json());
}

let IP; //For tracking
json(`https://api.ipdata.co?api-key=MyKey`).then(data => {
  IP = data.ip;
  console.log("Ip: " + data.ip);
  console.log("City: " + data.city);
  console.log("State: " + data.region);
});

How would I implement the x-forwarded-for in my code?

Hey!

You need some kind of reference to the inbound request. With ExpressJS, this is what you would do:

app.get('/', (req, res) => {
  const ip = req.get('X-Forwarded-For');

  // Call geolocation API
  // ...

  res.end();
});

Thank you for the example, but my service no longer functions. Every time I try to load it, it returns an error 502. When checking logs, no errors appear, and it claims to be a healthy service. Otherwise, the page won’t load at all. I won’t even get an error page. It is completely blank.