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:
co-authored by
Claude Sonnet 4.6
parent
4f30ed4447
commit
5bae03e5a3
@@ -1922,7 +1922,7 @@ let activePhone = '';
|
||||
async function loadConvs() {
|
||||
const list = document.getElementById('convList');
|
||||
try {
|
||||
const r = await fetch('/admin/chat-convs');
|
||||
const r = await fetch('/admin/chat?api=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-msgs?phone=' + encodeURIComponent(phone));
|
||||
const r = await fetch('/admin/chat?api=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', {
|
||||
method:'POST',
|
||||
headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({phone:activePhone, text})
|
||||
|
||||
Reference in New Issue
Block a user