Skip to content

Terminal WebSocket URL contains a double slash when the server URL ends with / #45891

Closed

Description

@sdivyanshu90

Description

When a configured server URL ends with /, opening a terminal constructs its WebSocket URL with a double slash before the PTY route. Servers and reverse proxies that do not normalize repeated slashes can reject the connection with a 404, leaving the terminal unable to connect.

The terminal URL helper appends the PTY route directly to the server URL. For example, combining https://example.test/ with /api/pty/pty_test/connect produces a pathname beginning with //api. Parsing the base URL first and joining the pathname at a single slash boundary would preserve the server path while avoiding the duplicate separator.

Plugins

N/A

OpenCode version

N/A (reproduced in the URL helper)

Steps to reproduce

  1. Configure the server URL as https://example.test/, including the trailing slash.
  2. Create a terminal connection with PTY ID pty_test.
  3. Inspect the WebSocket URL produced for the terminal connection.

Observed URL:

wss://example.test//api/pty/pty_test/connect

Expected URL:

wss://example.test/api/pty/pty_test/connect

The same result can be reproduced directly by evaluating new URL("https://example.test//api/pty/pty_test/connect").pathname, which returns //api/pty/pty_test/connect.

Screenshot and/or share link

Not provided; the generated URL above is the deterministic reproduction.

Operating System

All

Terminal

Web and desktop terminal

Activity

  1. sdivyanshu90 commented on Sep 19, 2026

    @sdivyanshu90
    ContributorAuthor

    Could you please review this issue?

  2. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    This is fixed in v2: terminal WebSocket URLs are joined relative to the server URL, preserving its base path without adding a second slash before api/pty. To install v2, run npm i -g @opencode/cli@latest (or update the desktop app). If you still see this on v2, please open a new issue with the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions