fix: rename chat API routes to avoid Nginx /admin/chat/* redirect conflict
/admin/chat/conversations → /admin/chat-convs /admin/chat/messages → /admin/chat-msgs /admin/chat/send → /admin/chat-send The production server was intercepting all subpaths of /admin/chat and redirecting them back to /admin/chat, so fetch never received JSON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
33869a6622
commit
4f30ed4447
@@ -1922,7 +1922,7 @@ let activePhone = '';
|
||||
async function loadConvs() {
|
||||
const list = document.getElementById('convList');
|
||||
try {
|
||||
const r = await fetch('/admin/chat/conversations');
|
||||
const r = await fetch('/admin/chat-convs');
|
||||
if (!r.ok) {
|
||||
list.innerHTML = \`<div style="padding:16px;color:#e53e3e;font-size:13px">Error \${r.status} al cargar conversaciones</div>\`;
|
||||
return;
|
||||
@@ -1992,7 +1992,7 @@ async function loadMessages(phone) {
|
||||
msgsDiv.innerHTML = '<div style="text-align:center;padding:20px;color:#a0a8b8">Cargando...</div>';
|
||||
let data;
|
||||
try {
|
||||
const r = await fetch('/admin/chat/messages?phone=' + encodeURIComponent(phone));
|
||||
const r = await fetch('/admin/chat-msgs?phone=' + encodeURIComponent(phone));
|
||||
if (!r.ok) {
|
||||
msgsDiv.innerHTML = \`<div style="text-align:center;padding:20px;color:#e53e3e">Error \${r.status}</div>\`;
|
||||
return;
|
||||
@@ -2064,7 +2064,7 @@ async function sendMsg() {
|
||||
if (!text || !activePhone) return;
|
||||
document.getElementById('sendBtn').disabled = true;
|
||||
try {
|
||||
const r = await fetch('/admin/chat/send', {
|
||||
const r = await fetch('/admin/chat-send', {
|
||||
method:'POST',
|
||||
headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({phone:activePhone, text})
|
||||
|
||||
+3
-3
@@ -91,9 +91,9 @@ $routes = [
|
||||
['GET', '/admin/webhook/stream', fn() => DashboardController::stream()],
|
||||
['GET', '/admin/webhook/raw', fn() => DashboardController::getRaw()],
|
||||
['GET', '/admin/chat', fn() => DashboardController::chat()],
|
||||
['GET', '/admin/chat/conversations', fn() => DashboardController::chatConversations()],
|
||||
['GET', '/admin/chat/messages', fn() => DashboardController::chatMessages()],
|
||||
['POST', '/admin/chat/send', fn() => DashboardController::chatSend()],
|
||||
['GET', '/admin/chat-convs', fn() => DashboardController::chatConversations()],
|
||||
['GET', '/admin/chat-msgs', fn() => DashboardController::chatMessages()],
|
||||
['POST', '/admin/chat-send', fn() => DashboardController::chatSend()],
|
||||
|
||||
// ─── Páginas legales (requeridas por Meta/WhatsApp Business) ────────────
|
||||
['GET', '/politicas', fn() => serveHtml('politicas.html')],
|
||||
|
||||
Reference in New Issue
Block a user