Fix Agentic Ops UI auth — use shared authHeaders/getToken.

Fixes 401 not authenticated on roster/inbox when logged into Desk.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ligbox Spec Hub 2026-06-20 06:22:36 +00:00
parent 92148e5980
commit 40bb16bbc9
2 changed files with 8 additions and 6 deletions

View file

@ -3,11 +3,13 @@
let state = { threadId: null, selectedAgent: 'A6' };
async function api(path, opts = {}) {
const h = { ...(opts.headers || {}) };
if (!(opts.body instanceof FormData)) h['Content-Type'] = 'application/json';
const t = window.DeskAuth?.getToken?.();
if (t) h.Authorization = `Bearer ${t}`;
const r = await fetch(`/api/v1/agents${path}`, { ...opts, headers: h });
const h = authHeaders({ ...(opts.headers || {}) });
if (!(opts.body instanceof FormData) && !h['Content-Type']) h['Content-Type'] = 'application/json';
const r = await fetchWithTimeout(`/api/v1/agents${path}`, { ...opts, headers: h });
if (r.status === 401) {
logout();
throw new Error('sessão expirada — faça login novamente');
}
if (!r.ok) throw new Error(`${r.status} ${(await r.text()).slice(0, 200)}`);
return r.json();
}

View file

@ -443,7 +443,7 @@
<script src="/assets/tickets-workspace.js?v=20260619tickets2"></script>
<script src="/assets/tickets-detail-panel.js?v=20260619tickets2"></script>
<script src="/assets/servicos.js?v=20260620agentic"></script>
<script src="/assets/agentic-ops.js?v=20260620agentic"></script>
<script src="/assets/agentic-ops.js?v=20260620agentic2"></script>
<script src="/assets/app.js?v=20260620agentic"></script>
</body>
</html>