fix front
All checks were successful
Build SMS Gateway / Build image (push) Successful in 16s

This commit is contained in:
2026-02-02 07:20:37 +07:00
parent f72f335807
commit d71d83a044
3 changed files with 18 additions and 5 deletions

View File

@@ -1 +1 @@
0.3.4 0.3.5

View File

@@ -188,9 +188,15 @@
async function loadBalance() { async function loadBalance() {
try { try {
const res = await fetch(basePath + "/balance"); const config = window.SMS_CONFIG || {};
const params = new URLSearchParams({ login: config.login, psw: config.psw });
const res = await fetch(basePath + "/balance?" + params);
const data = await res.json(); const data = await res.json();
document.getElementById("balance").textContent = data.balance; if (data.error) {
document.getElementById("balance").textContent = "Auth Error";
} else {
document.getElementById("balance").textContent = data.balance;
}
} catch (err) { } catch (err) {
document.getElementById("balance").textContent = "Error"; document.getElementById("balance").textContent = "Error";
} }

View File

@@ -103,9 +103,16 @@ router.get("/balance", (req, res) => {
// Serve static files // Serve static files
router.use(express.static(path.join(__dirname, "public"))); router.use(express.static(path.join(__dirname, "public")));
// GET / - serve main page // GET / - serve main page with injected credentials
router.get("/", (req, res) => { router.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "public", "index.html")); const indexPath = path.join(__dirname, "public", "index.html");
let html = fs.readFileSync(indexPath, "utf8");
// Inject credentials for frontend
const configScript = `<script>window.SMS_CONFIG = { login: "${AUTH_LOGIN || ""}", psw: "${AUTH_PASSWORD || ""}" };</script>`;
html = html.replace("</head>", configScript + "</head>");
res.send(html);
}); });
// Mount router at BASE_PATH // Mount router at BASE_PATH