Skip to content

Commit 5e7f08a

Browse files
committed
fix(cors): expose the API response headers a browser client needs
Without `Access-Control-Expose-Headers` a browser can read only the six CORS-safelisted response headers, so the rate-limit budget, the `Retry-After` a 429 or 503 asks the caller to observe, and the request/run correlation ids were all on the wire but invisible to `fetch()`. Server-to-server callers were unaffected, which is why it went unnoticed. Exposed on the default `/api` policy only. The per-route `CORS_RULES` entries are wildcard-origin public endpoints and opt in individually if they ever need it, so this does not widen what an anonymous cross-origin caller can read from them.
1 parent 19e8b01 commit 5e7f08a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

apps/sim/proxy.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ describe('resolveApiCorsPolicy', () => {
128128
origin: 'https://app.sim.test',
129129
credentials: true,
130130
methods: 'GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS',
131+
exposeHeaders:
132+
'Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-Request-Id, X-Run-Id',
131133
headers: expect.stringContaining('Authorization'),
132134
})
133135
})

0 commit comments

Comments
 (0)