Fix double /api prefix in fetchAccesses by using ENDPOINTS constant
fetchAccesses was passing the hardcoded absolute path /api/dashboard/accesses to get(), which prepends BASE_URL (/api), producing /api/api/dashboard/accesses. Added ENDPOINTS.dashboardAccesses and switched to use it, consistent with every other function in dashboard.ts.
This commit is contained in:
@@ -4,17 +4,14 @@ This document breaks the entire BanGUI project into development stages, ordered
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ✅ FIXED — Blocklist import: `No module named 'fail2ban'` on every IP (2026-03-01)
|
## ✅ FIXED — Access list 404: `/api/api/dashboard/accesses` double prefix (2026-03-01)
|
||||||
|
|
||||||
**Root cause:** In `app/main.py`, the `fail2ban-master` path was computed using
|
**Root cause:** `fetchAccesses` in `src/api/dashboard.ts` passed the hardcoded absolute path
|
||||||
`Path(__file__).resolve().parents[2] / "fail2ban-master"`. This resolves correctly
|
`/api/dashboard/accesses` directly to `get()`. Because `get()` prepends `BASE_URL` (`/api`),
|
||||||
in local dev (`backend/app/main.py` → repo root) but resolves to `/fail2ban-master`
|
the resulting URL became `/api/api/dashboard/accesses`, which has no backend route.
|
||||||
inside the Docker container (where the source is copied to `/app/app/main.py`),
|
|
||||||
so `fail2ban` was never added to `sys.path` and `pickle.loads()` raised
|
|
||||||
`ModuleNotFoundError: No module named 'fail2ban'` for every socket response.
|
|
||||||
|
|
||||||
**Fix:** Replaced the hardcoded `parents[2]` with a walk-up loop
|
**Fix:** Added `dashboardAccesses: "/dashboard/accesses"` to `ENDPOINTS` in `src/api/endpoints.ts`
|
||||||
(`_find_fail2ban_master()`) that iterates over all ancestors until it finds a
|
and changed `fetchAccesses` to use `ENDPOINTS.dashboardAccesses` — consistent with every other
|
||||||
`fail2ban-master/` sibling directory — correct in both local dev and Docker.
|
function in the same file.
|
||||||
|
|
||||||
**Commit:** `19bb94e` — _Fix fail2ban-master path resolution for Docker container_
|
**Commit:** _Fix double /api prefix in fetchAccesses by using ENDPOINTS constant_
|
||||||
@@ -63,6 +63,6 @@ export async function fetchAccesses(
|
|||||||
page: String(page),
|
page: String(page),
|
||||||
page_size: String(pageSize),
|
page_size: String(pageSize),
|
||||||
});
|
});
|
||||||
return get<AccessListResponse>(`/api/dashboard/accesses?${params.toString()}`);
|
return get<AccessListResponse>(`${ENDPOINTS.dashboardAccesses}?${params.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export const ENDPOINTS = {
|
|||||||
dashboardStatus: "/dashboard/status",
|
dashboardStatus: "/dashboard/status",
|
||||||
dashboardBans: "/dashboard/bans",
|
dashboardBans: "/dashboard/bans",
|
||||||
dashboardBansByCountry: "/dashboard/bans/by-country",
|
dashboardBansByCountry: "/dashboard/bans/by-country",
|
||||||
|
dashboardAccesses: "/dashboard/accesses",
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Jails
|
// Jails
|
||||||
|
|||||||
Reference in New Issue
Block a user