-
-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Dupe Check
- I have searched Swetrix bugs and there are no duplicates
Describe the bug
Remark: I previously reported this in a wrong repository,
"For the unique (and live) visitor functionality to work properly, each request must have the User-Agent
and X-Client-IP-Address
HTTP headers set. If you don't set these headers, the API will still work, but the unique visitor count will be incorrect."
X-Client-IP-Address
is non-standard. Browsers don't provide it.
You can use this instruction how to get IP address (when there is no X-Client-IP-Address
) if you don't know how. Particularly, you can write code like:
const express = require('express');
const app = express();
app.get('/get-ip', (req, res) => {
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
res.json({ ip });
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Note, that we don't need a separate endpoint /get-ip
, but can put code like the above in existing API enpoint(s),
To reproduce
Go to a site without X-Client-IP-Address
. Visitors are mis-counted.
Expected behavior
Visits are counted correctly.
Screenshots
No response
Regression
No, this bug or issue has existed throughout my experience using Swetrix
Additional context
No response
Are you using Swetrix cloud version or self-hosted?
I am using Swetrix cloud version (swetrix.com)
Does this block you from using Swetrix?
Yes, this issue prevents me from using Swetrix.