mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-06 23:03:24 +00:00
fix(server): don't forward host directory to remote workspace (#40136)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
aefaf140c1
commit
703d09f306
2 changed files with 14 additions and 0 deletions
|
|
@ -34,5 +34,12 @@ export function workspaceProxyURL(target: string | URL, requestURL: URL) {
|
|||
proxyURL.search = requestURL.search
|
||||
proxyURL.hash = requestURL.hash
|
||||
proxyURL.searchParams.delete("workspace")
|
||||
// The `directory` param is the *host's* working directory (e.g. a Windows
|
||||
// path like `F:\proj`). It is meaningless — and dangerous — on the remote:
|
||||
// the sandbox would `path.resolve` it against its own cwd, producing a bogus
|
||||
// path like `/home/daytona/workspace/repo/F:\proj` that does not exist and
|
||||
// crashes prompt handling. Drop it so the remote falls back to its own
|
||||
// project root. This mirrors ProxyUtil.headers stripping `x-opencode-directory`.
|
||||
proxyURL.searchParams.delete("directory")
|
||||
return proxyURL
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,13 @@ describe("workspaceProxyURL", () => {
|
|||
expect(result.searchParams.get("keep")).toBe("yes")
|
||||
})
|
||||
|
||||
test("strips the host directory param so the remote resolves its own root", () => {
|
||||
const url = new URL("http://localhost/session/abc?directory=F%3A%5Cproj&keep=yes")
|
||||
const result = workspaceProxyURL("http://remote:8080/base", url)
|
||||
expect(result.searchParams.get("directory")).toBeNull()
|
||||
expect(result.searchParams.get("keep")).toBe("yes")
|
||||
})
|
||||
|
||||
test("preserves hash from request", () => {
|
||||
const url = new URL("http://localhost/page#section")
|
||||
const result = workspaceProxyURL("http://remote:8080", url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue