修复Prometheus连接错误的问题

This commit is contained in:
CN-JS-HuiBai
2026-04-04 17:17:06 +08:00
parent 7baf628e0e
commit a46285c592
2 changed files with 11 additions and 4 deletions

View File

@@ -6,8 +6,12 @@ const QUERY_TIMEOUT = 10000;
* Create an axios instance for a given Prometheus URL
*/
function createClient(baseUrl) {
let url = baseUrl.replace(/\/+$/, '');
if (!/^https?:\/\//i.test(url)) {
url = 'http://' + url;
}
return axios.create({
baseURL: baseUrl.replace(/\/+$/, ''),
baseURL: url,
timeout: QUERY_TIMEOUT
});
}