Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix(console): stop blank /chat by rewriting OpenWork asset URLs #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
fix(console): stop blank /chat by rewriting OpenWork asset URLs #188
Changes from all commits
9ff5fa0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewrite only fixes static HTML attributes, but the proxied OpenWork bundle still derives its server base from
window.location.origin:resolveOpenworkConnection()falls back to the bare origin inapps/chat/src/react-app/shell/openwork-connection.tslines 92 to 95, andcreateOpenworkServerClient()then calls root paths such as/workspacesinapps/chat/src/app/lib/openwork-server.tsline 1339. Because this middleware only proxies/chat/*, those runtime requests hit the Next console origin instead of the workspace and the loaded UI cannot list workspaces or sessions. Inject or rewrite the OpenWork base to/chat(or proxy the required root API paths) along with the asset URLs.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep workspace redirects on the console proxy.
A full upstream redirect such as
https://workspace.example/settingsbecomeshttps://workspace.example/chat/settings. Atapps/console/src/middleware.ts, Lines 68-70 forward that URL to the browser. The browser leaves the console origin instead of requesting/chat/settings, so the console-scoped cookie cannot support the redirected request.Pass the workspace origin to this helper. For a full URL with that origin, return
/chat${pathname}${search}${hash}. Preserve third-party and non-HTTP URLs. Also parse the pathname before testing the prefix so/chat?tab=xis not double-prefixed and/chattyis not treated as/chat.Add coverage for a full workspace URL, an external OAuth URL, query and fragment preservation, and
/chat?tab=x.Proposed fix
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the workspace responds with an absolute
Location, this code keeps that upstream origin and only changes the path. In productionCONSOLE_WORKSPACE_URLcan be a private/internal Railway host, so a redirect likehttp://commonplace-workspace.railway.internal/settingswould be sent to the browser ashttp://commonplace-workspace.railway.internal/chat/settings, bypassing the console origin and failing for users; external absolute redirects are also mutated. For proxied redirects, same-upstream absolute locations should become console-relative/chat..., while other origins should be left alone.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this serves the rewritten OpenWork HTML at
/chat, only the asset URLs are moved under the proxy prefix. I checked the proxied app: it mounts a plainBrowserRouterwith no basename inapps/chat/src/index.react.tsxlines 40 and 48, and its wildcard route redirects unknown paths to/sessioninapps/chat/src/react-app/shell/app-root.tsxlines 289 to 290. As soon as the now-loadable bundle runs on/chat, it matches the wildcard and navigates the browser to console-root/session, outside this middleware, so/chatstill will not stay on the OpenWork UI. Configure a/chatbasename or otherwise rewrite the route base along with the assets.Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.