fix: guard EventSource when API_BASE_URL unset - #104
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| const base = API_BASE_URL || window.location.origin; | ||
| const url = new URL(`/stream/${state.currentConversation.id}`, base); |
There was a problem hiding this comment.
[P1] Preserve path prefixes when building EventSource URL
Building the URL via new URL('/stream/...', base) resets the path component of base when it contains a subpath. If VITE_API_BASE_URL is configured as https://example.com/api, the previous string concatenation produced https://example.com/api/stream/..., but the new implementation now resolves to https://example.com/stream/..., dropping the /api prefix and causing the SSE connection to hit the wrong endpoint. Construct the URL without stripping path segments (e.g. avoid the leading / or ensure the base already includes the trailing slash).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Ensured the EventSource URL builder preserves any existing API path prefixes by appending a trailing slash to the base and removing the leading slash from the stream path frontend/chat-ui/src/components/ChatWindow.jsxL15-L19
Testing
- ✅
npm test
903e955
into
codex/create-shared-api_base_url-constant
Summary
window.location.originwhenAPI_BASE_URLis absentTesting
npm testhttps://chatgpt.com/codex/tasks/task_e_68bb656927f8832182d62be9febcc3aa