Skip to content

Commit 51535d8

Browse files
authored
fix(app): skip url password setting for same-origin server and web app (#19923)
1 parent 38f8714 commit 51535d8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/app/src/components/terminal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const Terminal = (props: TerminalProps) => {
174174
const auth = server.current?.http
175175
const username = auth?.username ?? "opencode"
176176
const password = auth?.password ?? ""
177+
const sameOrigin = new URL(url, location.href).origin === location.origin
177178
let container!: HTMLDivElement
178179
const [local, others] = splitProps(props, ["pty", "class", "classList", "autoFocus", "onConnect", "onConnectError"])
179180
const id = local.pty.id
@@ -519,8 +520,11 @@ export const Terminal = (props: TerminalProps) => {
519520
next.searchParams.set("directory", directory)
520521
next.searchParams.set("cursor", String(seek))
521522
next.protocol = next.protocol === "https:" ? "wss:" : "ws:"
522-
next.username = username
523-
next.password = password
523+
if (!sameOrigin && password) {
524+
// For same-origin requests, let the browser reuse the page's existing auth.
525+
next.username = username
526+
next.password = password
527+
}
524528

525529
const socket = new WebSocket(next)
526530
socket.binaryType = "arraybuffer"

0 commit comments

Comments
 (0)