Skip to content

Zen/Go API endpoints missing Access-Control-Allow-Origin on actual responses (CORS fails for browser-based clients) #41224

Closed as not planned

Description

@holygloria

Description

Description

The OpenCode Zen/Go endpoints (e.g. https://opencode.ai/zen/go/v1/models) do not include the Access-Control-Allow-Origin header on the actual GET/POST responses, even though the OPTIONS preflight returns one. As a result, browser-based API clients that make direct cross-origin requests (e.g. SillyTavern's character-card model query) fail with a CORS error / "Failed to fetch".

Steps to reproduce

  1. Open a browser-based client (e.g. SillyTavern) and make a direct fetch to https://opencode.ai/zen/go/v1/models from an arbitrary origin (e.g. http://localhost:8000).
  2. Observe the request fails in the browser with a CORS error.
  3. Compare with a provider that works, e.g. https://api.deepseek.com/v1/models, which returns access-control-allow-origin on the actual response.

Curl evidence (actual GET response headers):

# opencode.ai — actual GET response has NO Access-Control-Allow-Origin
$ curl -s -o /dev/null -D - "https://opencode.ai/zen/go/v1/models" -H "Origin: http://localhost:8000"
HTTP/1.1 200 OK
Content-Type: application/json
Server: cloudflare
CF-RAY: ...-IAD
# <-- no access-control-* header at all

# api.deepseek.com — actual GET response DOES have it
$ curl -s -o /dev/null -D - "https://api.deepseek.com/v1/models" -H "Origin: http://localhost:8000"
HTTP/1.1 401 Authorization Required
access-control-allow-credentials: true
access-control-allow-origin: http://localhost:8000

Note: the OPTIONS preflight for opencode.ai does return CORS headers (Access-Control-Allow-Origin: *, access-control-allow-headers: Content-Type, Authorization), but browsers also check the actual response, which lacks Access-Control-Allow-Origin, so the request is still blocked.

Expected behavior
Actual GET/POST responses should include an appropriate Access-Control-Allow-Origin header (matching the request origin or * when credentials are not required) so that cross-origin browser clients can consume the API.

Actual behavior
Actual responses return no Access-Control-Allow-Origin, so browsers block them with a CORS error. This only works when requests are routed through a server-side proxy (same-origin), not for direct browser fetches.

Environment
Endpoint(s): https://opencode.ai/zen/v1/*, https://opencode.ai/zen/go/v1/*
Affected client: any browser-based tool doing direct cross-origin fetches (reproduced with SillyTavern v1.18 character-card API query)

### Plugins

SillyTavern v1.18 character-card API query

### OpenCode version

https://opencode.ai/zen/go/v1

### Steps to reproduce

_No response_

### Screenshot and/or share link

<img width="678" height="442" alt="Image" src="https://github.com/user-attachments/assets/4a225107-1b46-4e19-9854-a52ca72235bc" />

<img width="468" height="206" alt="Image" src="https://github.com/user-attachments/assets/687df119-5e24-4afd-ac5f-a73b0d2949aa" />

<img width="579" height="396" alt="Image" src="https://github.com/user-attachments/assets/c95e39cf-c80b-45e1-839a-67052769fc34" />

### Operating System

Windows 11

### Terminal

SillyTavern v1.18 character-card API query

Activity

  1. github-actions commented on Aug 8, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    If your issue is distinct (preflight now works but actual responses still lack the header), please add a comment clarifying that so maintainers can track them separately.

  2. holygloria commented on Aug 8, 2026

    @holygloria
    Author

    Thanks for the note. I believe this is a distinct issue from #31041.

    In this case, the OPTIONS preflight is not failing — it returns 200 with proper CORS headers:
    Access-Control-Allow-Origin: *, access-control-allow-headers: Content-Type, Authorization, access-control-allow-methods: GET, POST, OPTIONS (verified via curl).

    The problem is that the actual GET/POST response (e.g. /zen/go/v1/models) does not include Access-Control-Allow-Origin at all:

    $ curl -s -o /dev/null -D - "https://opencode.ai/zen/go/v1/models" -H "Origin: http://localhost:8000/" HTTP/1.1 200 OK Content-Type: application/json Server: cloudflare

    <-- no access-control-* header on the actual response

    Even after a successful preflight, browsers still validate the Access-Control-Allow-Origin header on the actual response. Since it is missing, the request is blocked with a CORS error ("Failed to fetch"). A same-origin server-side proxy works around it, which confirms the root cause.

    So: #31041 covers the preflight (OPTIONS 404) problem, while this issue covers the missing Access-Control-Allow-Origin on actual responses. I'd suggest keeping them separate, or merging #31041 into this one if the maintainers prefer a single CORS tracking issue.

  3. github-actions commented on Oct 9, 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.

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

Metadata

Metadata

Assignees

No one assigned

    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