fix: consolidate all chat API calls onto /admin/chat with ?api= param

Nginx intercepts any request to /admin/chat/* sub-routes. Fix by handling
all chat API requests on the same /admin/chat path using query params:
  GET  /admin/chat?api=convs        → conversations list
  GET  /admin/chat?api=msgs&phone=X → messages for a phone
  POST /admin/chat                  → send message

JS fetch URLs updated accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-27 19:48:21 -05:00
co-authored by Claude Sonnet 4.6
parent 4f30ed4447
commit 5bae03e5a3
2 changed files with 10 additions and 7 deletions
+7 -4
View File
@@ -90,10 +90,13 @@ $routes = [
['GET', '/admin/webhook/stream/sse', fn() => DashboardController::streamSse()],
['GET', '/admin/webhook/stream', fn() => DashboardController::stream()],
['GET', '/admin/webhook/raw', fn() => DashboardController::getRaw()],
['GET', '/admin/chat', fn() => DashboardController::chat()],
['GET', '/admin/chat-convs', fn() => DashboardController::chatConversations()],
['GET', '/admin/chat-msgs', fn() => DashboardController::chatMessages()],
['POST', '/admin/chat-send', fn() => DashboardController::chatSend()],
['GET', '/admin/chat', fn() => (function () {
$api = $_GET['api'] ?? '';
if ($api === 'convs') { DashboardController::chatConversations(); return; }
if ($api === 'msgs') { DashboardController::chatMessages(); return; }
DashboardController::chat();
})()],
['POST', '/admin/chat', fn() => DashboardController::chatSend()],
// ─── Páginas legales (requeridas por Meta/WhatsApp Business) ────────────
['GET', '/politicas', fn() => serveHtml('politicas.html')],