This commit is contained in:
@@ -188,9 +188,15 @@
|
||||
|
||||
async function loadBalance() {
|
||||
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();
|
||||
if (data.error) {
|
||||
document.getElementById("balance").textContent = "Auth Error";
|
||||
} else {
|
||||
document.getElementById("balance").textContent = data.balance;
|
||||
}
|
||||
} catch (err) {
|
||||
document.getElementById("balance").textContent = "Error";
|
||||
}
|
||||
|
||||
11
server.js
11
server.js
@@ -103,9 +103,16 @@ router.get("/balance", (req, res) => {
|
||||
// Serve static files
|
||||
router.use(express.static(path.join(__dirname, "public")));
|
||||
|
||||
// GET / - serve main page
|
||||
// GET / - serve main page with injected credentials
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user