zai-org / zai-org/feedback

[Bug] api.z.ai Edge Omits CORS Headers on OPTIONS Preflight, Breaking All In-Browser Clients

Open
#590 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Problem Description

Since ~2026-09-07, preflight HTTP OPTIONS requests sent to api.z.ai return HTTP/2 200 OK but completely omit all Access-Control-* response headers. As a result, standard in-browser fetch() / XMLHttpRequest calls fail with TypeError: Failed to fetch during CORS preflight validation.

Community Report Reference

Verification & Live Reproduction

Executing an OPTIONS preflight request against the international gateway:

curl -i -X OPTIONS "https://api.z.ai/api/coding/paas/v4/chat/completions" \
  -H "Origin: https://example.com" \
  -H "Access-Control-Request-Method: POST" \
  -H "Access-Control-Request-Headers: authorization,content-type"

Observed Response (api.z.ai):

HTTP/2 200 
date: Wed, 09 Sep 2026 12:57:09 GMT
content-type: text/plain; charset=utf-8
alt-svc: h3=":443"; ma=3600
set-cookie: acw_tc=...
ga-traceid: 921950576098d28ee38fbbb68587a544
x-request-id: a901c3a6-3149-4a36-b70a-a4fdbe03fc80
vary: Origin

(Notice: Completely missing access-control-allow-origin, access-control-allow-methods, and access-control-allow-headers).


Comparative Evidence (open.bigmodel.cn Working Correctly)

Probing the CN edge with the identical request:

curl -i -X OPTIONS "https://open.bigmodel.cn/api/paas/v4/chat/completions" \
  -H "Origin: https://example.com" \
  -H "Access-Control-Request-Method: POST" \
  -H "Access-Control-Request-Headers: authorization,content-type"

Observed Response (open.bigmodel.cn):

HTTP/2 200 
vary: Origin
vary: Access-Control-Request-Method
vary: Access-Control-Request-Headers
access-control-allow-origin: https://example.com
access-control-allow-methods: POST
access-control-allow-headers: authorization, content-type
access-control-allow-credentials: true
access-control-max-age: 3600

Key Observations & Impact
  1. Direct POST Still Works: Direct server-side POST requests directly to api.z.ai succeed with HTTP 200 and correctly return Access-Control-Allow-Origin: <origin>.
  2. OPTIONS Regressed: Because browsers send an OPTIONS preflight whenever custom headers like Authorization: Bearer ... or Content-Type: application/json are specified, the absence of CORS response headers on OPTIONS kills all direct browser-based clients, web extensions, and web-based IDE plugins.
  3. Scope: Affects /api/coding/paas/v4, /api/paas/v4, /v1, /api/anthropic/v1 on the api.z.ai domain.
Recommended Fix

Restore the ingress / reverse-proxy CORS injection policy on the api.z.ai edge controller so that OPTIONS preflights mirror the configuration of open.bigmodel.cn (returning Access-Control-Allow-Origin, Access-Control-Allow-Methods: POST, OPTIONS, and Access-Control-Allow-Headers: Authorization, Content-Type, ...).


Regards,
Roman M.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files or tests are identified; start by running the provided curl OPTIONS request against the affected api.z.ai endpoints and comparing it with open.bigmodel.cn. Done means the api.z.ai edge returns the required Access-Control-Allow-Origin, Access-Control-Allow-Methods, and Access-Control-Allow-Headers headers for browser preflights.

Written by the indexing model from the issue text.

Assessment

Domain
api, infrastructure
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.