diff --git a/recharge.php b/recharge.php index 28e9592..99452bd 100644 --- a/recharge.php +++ b/recharge.php @@ -414,7 +414,10 @@ window.lastRechargeStatus = null; // Helper to get relative API path correctly regardless of subdir const getApiPath = () => { - return 'api/'; + // Determine the path to the api directory relative to current location + const loc = window.location.pathname; + const isRoot = loc.endsWith('/') || loc.endsWith('index.php') || loc.endsWith('recharge.php'); + return isRoot ? 'api/' : '../api/'; }; async function updateRate() {