From 163c74e25fa5872e892c2ca793e265f6c4744de8 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sat, 31 Jan 2026 10:00:59 +0100 Subject: [PATCH] fix(p2p): Use /api/factory/ path for CGI endpoints Separate static files from CGI scripts in uhttpd configuration: - Static files (index.html) served from /www - CGI scripts executed from /www/api/* - API base changed from /factory/ to /api/factory/ This fixes HAProxy routing where /factory/ serves the UI and /api/factory/* routes to the P2P API backend. Co-Authored-By: Claude Opus 4.5 --- .../root/etc/uci-defaults/99-secubox-p2p-api | 20 ++++++++++--------- .../secubox-p2p/root/www/factory/index.html | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package/secubox/secubox-p2p/root/etc/uci-defaults/99-secubox-p2p-api b/package/secubox/secubox-p2p/root/etc/uci-defaults/99-secubox-p2p-api index 91270123..66cac4c1 100644 --- a/package/secubox/secubox-p2p/root/etc/uci-defaults/99-secubox-p2p-api +++ b/package/secubox/secubox-p2p/root/etc/uci-defaults/99-secubox-p2p-api @@ -1,24 +1,26 @@ #!/bin/sh # Configure uhttpd instance for P2P REST API and Factory UI on port 7331 +# - Static files served from /www (includes /factory/index.html) +# - CGI scripts executed from /www/api/* (includes /api/factory/*) # Check if p2p_api instance already exists if ! uci -q get uhttpd.p2p_api >/dev/null 2>&1; then uci set uhttpd.p2p_api=uhttpd uci set uhttpd.p2p_api.listen_http='0.0.0.0:7331' - uci set uhttpd.p2p_api.home='/www/api' - uci set uhttpd.p2p_api.cgi_prefix='/' + uci set uhttpd.p2p_api.home='/www' + uci set uhttpd.p2p_api.cgi_prefix='/api' + uci set uhttpd.p2p_api.index_page='index.html' uci set uhttpd.p2p_api.no_symlinks='0' uci set uhttpd.p2p_api.no_dirlists='1' uci set uhttpd.p2p_api.script_timeout='60' uci set uhttpd.p2p_api.network_timeout='30' uci commit uhttpd -fi - -# Add alias for Factory UI (serves /www/factory at /factory/) -# This allows Factory UI to be served alongside the API on port 7331 -current_aliases=$(uci -q get uhttpd.p2p_api.alias 2>/dev/null) -if ! echo "$current_aliases" | grep -q "/factory/"; then - uci add_list uhttpd.p2p_api.alias='/factory/=/www/factory' +else + # Update existing config to fix paths + uci set uhttpd.p2p_api.home='/www' + uci set uhttpd.p2p_api.cgi_prefix='/api' + uci set uhttpd.p2p_api.index_page='index.html' + uci delete uhttpd.p2p_api.alias 2>/dev/null || true uci commit uhttpd fi diff --git a/package/secubox/secubox-p2p/root/www/factory/index.html b/package/secubox/secubox-p2p/root/www/factory/index.html index a5993345..ee5140a3 100644 --- a/package/secubox/secubox-p2p/root/www/factory/index.html +++ b/package/secubox/secubox-p2p/root/www/factory/index.html @@ -288,8 +288,8 @@ let catalogFilter = { search: '', type: 'all', status: 'all' }; let expandedServices = new Set(); - // API helpers - use same origin (HAProxy routes /factory/* to API) - const apiBase = '/factory/'; + // API helpers - use same origin (HAProxy routes /api/factory/* to P2P API backend) + const apiBase = '/api/factory/'; const api = { get: async (path) => {