Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Fix api requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh committed Jun 16, 2023
1 parent 0165d89 commit cbd6535
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dashboard-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ const fixHost = (host) => {
host = host.substring(0, host.length - 1);
}

return host;
return host.replace(/\/v1\/?$/, "");
}

NETDATA.chartRegistry = {
Expand Down Expand Up @@ -555,7 +555,7 @@ NETDATA.fixHost = function (host) {
host = host.substring(0, host.length - 1);
}

return host;
return host.replace(/\/v1\/?$/, "");
};


Expand Down
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ <h4 class="modal-title" id="gotoServerModalLabel"><span id="gotoServerName"></sp
window.NETDATA = null
}

fetch(location.origin + location.pathname + "/version.txt").then(function(res) {
const pathname = location.pathname.replace("/v1", "")
fetch(location.origin + pathname + "/version.txt").then(function(res) {
if (res.url && /index\.html/.test(res.url)) {
show404()
return
Expand Down
4 changes: 2 additions & 2 deletions src/utils/server-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ const getDefaultServer = () => {
.replace("index.html", "")
// todo consider .replace(/[^\/]*\.html/, "") (every .html file in the url)
.replace("default.html", "") // for netdata demo servers
return window.location.origin + pathname
return window.location.origin + pathname.replace(/\/v1\/?$/, "")
}

const source = getScriptSource()
return getPathFromScriptSource(source)
return getPathFromScriptSource(source).replace(/\/v1\/?$/, "")
}

// append "/" at the end, if it's not already there
Expand Down

0 comments on commit cbd6535

Please sign in to comment.