Description
All Zen API endpoints (/zen/v1/* and /zen/go/v1/*) return a 404 HTML page on CORS preflight (OPTIONS) requests, which blocks any browser-based client from calling the API. The actual POST endpoints are alive and working — this is purely a CORS preflight routing issue.
Evidence
Direct curl testing confirms the API backend is functional, but OPTIONS requests fall through to the frontend router:
| Endpoint |
Method |
Result |
/zen/v1/chat/completions |
POST |
✅ 401 "Invalid API key" (API is alive) |
/zen/go/v1/chat/completions |
POST |
✅ 401 "Invalid API key" (API is alive) |
/zen/v1/models |
GET |
✅ 200 (full model list returned) |
/zen/v1/chat/completions |
OPTIONS (preflight) |
❌ 404 — returns HTML "Not Found" page, no CORS headers |
/zen/go/v1/chat/completions |
OPTIONS (preflight) |
❌ 404 — same thing |
OPTIONS request/response:
curl -X OPTIONS \
-H "Origin: https://example.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: authorization,content-type" \
"https://opencode.ai/zen/v1/chat/completions"
Response: HTTP 404 with full HTML page (<title>Not Found | opencode</title>), zero CORS headers.
Browser console error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote
resource at https://opencode.ai/zen/v1/chat/completions.
(Reason: CORS header Access-Control-Allow-Origin missing). Status code: 404.
Impact
Root Cause
The API gateway is not handling OPTIONS requests — they fall through to the frontend SPA router, which returns a 404 HTML page. The server needs to respond to OPTIONS preflight requests with:
Access-Control-Allow-Origin: * (or specific origins)
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Max-Age: 86400
Environment
Description
All Zen API endpoints (
/zen/v1/*and/zen/go/v1/*) return a 404 HTML page on CORS preflight (OPTIONS) requests, which blocks any browser-based client from calling the API. The actual POST endpoints are alive and working — this is purely a CORS preflight routing issue.Evidence
Direct curl testing confirms the API backend is functional, but OPTIONS requests fall through to the frontend router:
/zen/v1/chat/completions/zen/go/v1/chat/completions/zen/v1/models/zen/v1/chat/completions/zen/go/v1/chat/completionsOPTIONS request/response:
Response: HTTP 404 with full HTML page (
<title>Not Found | opencode</title>), zero CORS headers.Browser console error:
Impact
/zen/v1/) and paid (/zen/go/v1/) endpoints are affectedRoot Cause
The API gateway is not handling OPTIONS requests — they fall through to the frontend SPA router, which returns a 404 HTML page. The server needs to respond to OPTIONS preflight requests with:
Access-Control-Allow-Origin: *(or specific origins)Access-Control-Allow-Methods: POST, GET, OPTIONSAccess-Control-Allow-Headers: Authorization, Content-TypeAccess-Control-Max-Age: 86400Environment
opencode.ai/zen/v1/*,opencode.ai/zen/go/v1/*