From 401a5d416941ba8783eb54dfdea55e5237188c93 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 1 Mar 2026 21:05:30 +0100 Subject: [PATCH] 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. --- Docs/Tasks.md | 19 ++++++++----------- frontend/src/api/dashboard.ts | 2 +- frontend/src/api/endpoints.ts | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Docs/Tasks.md b/Docs/Tasks.md index b0a8110..e66167c 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -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 -`Path(__file__).resolve().parents[2] / "fail2ban-master"`. This resolves correctly -in local dev (`backend/app/main.py` → repo root) but resolves to `/fail2ban-master` -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. +**Root cause:** `fetchAccesses` in `src/api/dashboard.ts` passed the hardcoded absolute path +`/api/dashboard/accesses` directly to `get()`. Because `get()` prepends `BASE_URL` (`/api`), +the resulting URL became `/api/api/dashboard/accesses`, which has no backend route. -**Fix:** Replaced the hardcoded `parents[2]` with a walk-up loop -(`_find_fail2ban_master()`) that iterates over all ancestors until it finds a -`fail2ban-master/` sibling directory — correct in both local dev and Docker. +**Fix:** Added `dashboardAccesses: "/dashboard/accesses"` to `ENDPOINTS` in `src/api/endpoints.ts` +and changed `fetchAccesses` to use `ENDPOINTS.dashboardAccesses` — consistent with every other +function in the same file. -**Commit:** `19bb94e` — _Fix fail2ban-master path resolution for Docker container_ \ No newline at end of file +**Commit:** _Fix double /api prefix in fetchAccesses by using ENDPOINTS constant_ \ No newline at end of file diff --git a/frontend/src/api/dashboard.ts b/frontend/src/api/dashboard.ts index a20c208..80caa88 100644 --- a/frontend/src/api/dashboard.ts +++ b/frontend/src/api/dashboard.ts @@ -63,6 +63,6 @@ export async function fetchAccesses( page: String(page), page_size: String(pageSize), }); - return get(`/api/dashboard/accesses?${params.toString()}`); + return get(`${ENDPOINTS.dashboardAccesses}?${params.toString()}`); } diff --git a/frontend/src/api/endpoints.ts b/frontend/src/api/endpoints.ts index 83a21c2..e0d2189 100644 --- a/frontend/src/api/endpoints.ts +++ b/frontend/src/api/endpoints.ts @@ -30,6 +30,7 @@ export const ENDPOINTS = { dashboardStatus: "/dashboard/status", dashboardBans: "/dashboard/bans", dashboardBansByCountry: "/dashboard/bans/by-country", + dashboardAccesses: "/dashboard/accesses", // ------------------------------------------------------------------------- // Jails