polis
polis copied to clipboard
client-report/src/util/url.js returns the wrong report URL for non-polis / xip.io sites
client-report/src/util/url.js checks the domain for a variety of included strings, returning fixed hostnames if matched. If you're not running on a proper pol.is domain, or xip.io, it returns localhost. This breaks reports. For example, see this report -- if you check the console you can see it's trying to access localhost, which is wrong.
If not polis assume localhost:
if ((-1 === document.domain.indexOf("pol.is")) && (-1 === document.domain.indexOf("polis.io"))) {
urlPrefix = localhost;
}
Fix only for specific URLs:
if (0 === document.domain.indexOf("192.168") || document.domain.includes(".xip.io")) {
urlPrefix = "http://" + document.location.hostname + ":" + document.location.port + "/";
}
I think the correct URL is specified in polis.config.js as SERVICE_URL, but even always having a fallback would be useful.