Skip to content

Opencode web change /sub-dir/ in url location? #13847

Closed as not planned
Closed as not planned

Description

@onixau-go

Question

To securely use the web version, it makes sense to use HTTPS through nginx.
This is already implemented and works.

server {
    listen 443 ssl;
    server_name ipv4;

    ssl_certificate /cert/ip/fullchain.pem;
    ssl_certificate_key /cert/ip/privkey.pem;

    location /sub-dir/ {
        proxy_pass http://localhost:port/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

But you can't change the access subdirectory.
Errors occur when logging in. The JavaScript loaded by the web version must be placed in the root of the domain. API requests are sent to the wrong URL. The server becomes unavailable.

Activity

  1. github-actions commented on Feb 16, 2026

    @github-actions
    Contributor

    This issue might be related to existing feature requests about web proxy configuration:

    These issues share similar concerns about running OpenCode web behind proxies with custom configurations. You may want to review them for context on ongoing work in this area.

  2. onixau-go commented on Feb 28, 2026

    @onixau-go
    Author
    <!doctype html>
    <html lang="en" style="background-color: var(--background-base)">
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>OpenCode</title>
        <link rel="icon" type="image/png" href="/favicon-96x96-v3.png" sizes="96x96" />
        <link rel="icon" type="image/svg+xml" href="/favicon-v3.svg" />
        <link rel="shortcut icon" href="/favicon-v3.ico" />
        <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-v3.png" />
        <link rel="manifest" href="/site.webmanifest" />
        <meta name="theme-color" content="#F8F7F7" />
        <meta name="theme-color" content="#131010" media="(prefers-color-scheme: dark)" />
        <meta property="og:image" content="/social-share.png" />
        <meta property="twitter:image" content="/social-share.png" />
        <script id="oc-theme-preload-script" src="/oc-theme-preload.js"></script>
        <script type="module" crossorigin src="/assets/index-D7E5miXu.js"></script>
        <link rel="stylesheet" crossorigin href="/assets/index-CLHnvSji.css">
      </head>
      <body class="antialiased overscroll-none text-12-regular overflow-hidden">
        <noscript>You need to enable JavaScript to run this app.</noscript>
        <div id="root" class="flex flex-col h-dvh p-px"></div>
      </body>
    </html>
    

    This HTML returns "index" when opened by Opencode Web.
    The problem is that all the relative paths specified in this HTML are relative to the root domain and do not assume the Opencode-Web editor is located at https://domain/opencode-folder/.

    Adding a period to all the relative paths is enough for everything to work.

    <script id="oc-theme-preload-script" src="./oc-theme-preload.js"></script>
        <script type="module" crossorigin src="./assets/index-D7E5miXu.js"></script>
    

    You may also need to modify all JavaScript fetch requests in the same way.

  3. github-actions commented on Apr 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  4. ramonpaolo commented on May 3, 2026

    @ramonpaolo

    I tried it now and it works

    You can try this PR?

    #25513

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

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions