From 3d222ac5f5759a36af01bd4728a79b5566f25232 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Tue, 23 Nov 2021 12:59:48 +0800 Subject: [PATCH] fix btoa is not define --- server/model/monitor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index c7ffa99ab..98a3421ee 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -87,8 +87,8 @@ class Monitor extends BeanModel { * for HTTP "basic" auth, as per RFC-7617 * @returns {string} */ - encodeB64(user, pass) { - return btoa(user + ":" + pass); + encodeBase64(user, pass) { + return Buffer.from(user + ":" + pass).toString("base64"); } /** @@ -156,7 +156,7 @@ class Monitor extends BeanModel { let basicAuthHeader = {}; if (this.basic_auth_user) { basicAuthHeader = { - "Authorization": "Basic " + this.encodeB64(this.basic_auth_user, this.basic_auth_pass), + "Authorization": "Basic " + this.encodeBase64(this.basic_auth_user, this.basic_auth_pass), }; }