Skip to content

fix(webapp): keep playground chat requests same-origin#4193

Merged
isshaddad merged 2 commits into
mainfrom
fix/playground-chat-same-origin-base-url
Jul 8, 2026
Merged

fix(webapp): keep playground chat requests same-origin#4193
isshaddad merged 2 commits into
mainfrom
fix/playground-chat-same-origin-base-url

Conversation

@isshaddad

Copy link
Copy Markdown
Collaborator

Problem

The agent playground chat builds its realtime transport baseURL from apiOrigin, but points it at a same-origin /resources/... dashboard route. When API_ORIGIN differs from APP_ORIGIN, the in/append POST goes cross-origin, fails the CORS preflight, and messages never reach the agent ("Failed to fetch").

It only reproduces where the two origins differ — not locally, where both default to localhost:3030.

Fixes #4149.

Fix

Build the base URL from window.location.origin (falling back to apiOrigin on SSR), so realtime traffic stays same-origin — the same approach AgentView.tsx already uses.

Testing

Typecheck passes. The CORS path only manifests when API_ORIGIN != APP_ORIGIN, so verify on test-cloud (can't reproduce locally).

@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9ad4a73

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This change modifies the playground chat resource base URL construction to prefer same-origin requests. In the browser, an origin variable now uses window.location.origin, falling back to apiOrigin when unavailable, and playgroundBaseURL is rebuilt using this origin instead of always defaulting to apiOrigin. A changelog entry was added documenting the fix for a "Failed to fetch" error previously encountered when sending messages in the agent playground chat in certain environments.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code change matches #4149 by switching the playground chat base URL to same-origin, which addresses the CORS failure.
Out of Scope Changes check ✅ Passed The changes stay focused on the playground chat URL fix and the accompanying changelog note.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise and accurately summarizes the main change: keeping playground chat requests same-origin.
Description check ✅ Passed The description clearly covers the problem, fix, and testing, though it does not fully follow the template sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/playground-chat-same-origin-base-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@isshaddad isshaddad marked this pull request as ready for review July 8, 2026 17:00

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@isshaddad isshaddad merged commit e0208f3 into main Jul 8, 2026
30 checks passed
@isshaddad isshaddad deleted the fix/playground-chat-same-origin-base-url branch July 8, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Dashboard playground chat fails with CORS error: /in/append preflight returns 400 on api.trigger.dev (agent run never receives message)

2 participants