From 6bf359f4d41e905761b22e5f0c5bbca52997cdd4 Mon Sep 17 00:00:00 2001 From: Kartikeya <176560021+karti-ai@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:53:26 -0700 Subject: [PATCH] fix: restore CORS + align frontend with /api/token endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The canonical-architecture rewrite dropped app.use(cors()) and moved the token route to POST /api/token ({room,identity,name}), but the frontend still called the old /pods/:id/token — causing "Failed to fetch" in the browser. Re-add CORS and update fetchPodToken to the new contract. Co-Authored-By: Claude Opus 4.8 --- backend/src/server.ts | 2 ++ frontend/src/lib/pod.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/server.ts b/backend/src/server.ts index 2a2acb5..414545d 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -1,4 +1,5 @@ import express from 'express'; +import cors from 'cors'; import { createServer } from 'node:http'; import { WebSocketServer } from 'ws'; import { AccessToken } from 'livekit-server-sdk'; @@ -8,6 +9,7 @@ import { recordOutcome } from './memory/store.js'; import type { InterventionOutcome } from '@podman/shared'; const app = express(); +app.use(cors()); app.use(express.json()); app.get('/health', (_req, res) => res.json({ ok: true })); diff --git a/frontend/src/lib/pod.ts b/frontend/src/lib/pod.ts index 22f714e..7fdcdd5 100644 --- a/frontend/src/lib/pod.ts +++ b/frontend/src/lib/pod.ts @@ -8,10 +8,10 @@ export async function fetchPodToken( identity: string, name: string, ): Promise<{ token: string; url: string }> { - const res = await fetch(`${BACKEND_URL}/pods/${encodeURIComponent(podId)}/token`, { + const res = await fetch(`${BACKEND_URL}/api/token`, { method: 'POST', headers: { 'content-type': 'application/json' }, - body: JSON.stringify({ identity, name }), + body: JSON.stringify({ room: podId, identity, name }), }); if (!res.ok) throw new Error(`token request failed: ${res.status}`); return res.json();