Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .server-changes/playground-chat-same-origin-base-url.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
area: webapp
type: fix
---

Fixed the agent playground chat failing to send messages ("Failed to fetch")
in some environments. Messages now reach the agent reliably.
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ function PlaygroundChat() {
return data.publicAccessToken;
}, [actionPath, agent.slug, chatId, tags, machine, maxAttempts, maxDuration, version, region]);

// Resource route prefix — all realtime traffic goes through session-authed routes
const playgroundBaseURL = `${apiOrigin}/resources/orgs/${organization.slug}/projects/${project.slug}/env/${environment.slug}/playground`;
// Same-origin resource routes: use the page origin, not apiOrigin, so in/append
// doesn't go cross-origin (CORS preflight) when API_ORIGIN != APP_ORIGIN.
const origin = typeof window !== "undefined" ? window.location.origin : apiOrigin;
const playgroundBaseURL = `${origin}/resources/orgs/${organization.slug}/projects/${project.slug}/env/${environment.slug}/playground`;

// The transport is constructed once (guarded ref below); reading
// `startSession` directly there would freeze its closure to the
Expand Down