From c3d8893436da0fece4e2988fda9402f4f0b5ffe2 Mon Sep 17 00:00:00 2001 From: BTCforPlebs Date: Sat, 27 Sep 2025 00:30:45 -0400 Subject: [PATCH] small --- public/assets/js/config.js | 7 +++++++ public/assets/js/home.js | 6 +++--- public/index.html | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 public/assets/js/config.js diff --git a/public/assets/js/config.js b/public/assets/js/config.js new file mode 100644 index 0000000..b05284b --- /dev/null +++ b/public/assets/js/config.js @@ -0,0 +1,7 @@ +// Configuration for the frontend +const config = { + // Use services.btcforplebs.com in production, localhost in development + apiBaseUrl: window.location.hostname === 'localhost' + ? 'http://localhost:5252' + : 'https://services.btcforplebs.com' +}; \ No newline at end of file diff --git a/public/assets/js/home.js b/public/assets/js/home.js index ee06ce3..99a18d1 100644 --- a/public/assets/js/home.js +++ b/public/assets/js/home.js @@ -4,7 +4,7 @@ let linkStatuses = {}; // Fetch statuses on page load document.addEventListener('DOMContentLoaded', () => { // Fetch statuses immediately but keep folders closed - fetch("https://services.btcforplebs.com/api/link-status") + fetch(`${config.apiBaseUrl}/api/link-status`) .then(res => res.json()) .then(statuses => { linkStatuses = statuses; // Store for later use @@ -43,7 +43,7 @@ function toggleFolder(folderId, buttonId) { if (Object.keys(linkStatuses).length > 0) { updateFolderStatuses(folder, linkStatuses); } else { - fetch("https://services.btcforplebs.com/api/link-status") + fetch(`${config.apiBaseUrl}/api/link-status`) .then(res => res.json()) .then(statuses => { linkStatuses = statuses; @@ -60,7 +60,7 @@ async function init() { try { // Fetch the status first console.log("Fetching statuses..."); - const response = await fetch("https://services.btcforplebs.com/api/link-status"); + const response = await fetch(`${config.apiBaseUrl}/api/link-status`); const statuses = await response.json(); console.log("Got statuses:", statuses); diff --git a/public/index.html b/public/index.html index 3e57b3a..a523236 100644 --- a/public/index.html +++ b/public/index.html @@ -1,5 +1,9 @@ - + + + + + et="UTF-8"> BTCforPlebs