Repository navigation
Description
Component
decdn gateway --public-url: the CORS headers on content responses (PUBLIC_EXPOSED in crates/cli/src/commands/gateway.rs).
Version
v0.3.0 and main (e7e67e6).
Steps to reproduce
- Run a public gateway behind its TLS-terminating proxy, with the proxy set to compress responses (gzip/br). The gateway itself never encodes, but any compressing proxy or CDN in front of it does.
- From a page on another origin,
fetchan unverified or unsized body from the gateway, e.g. through@decdn/clientwithverify: false. - Read
response.headers.get("content-encoding").
Expected behavior
The page can tell that the body was decoded on the way. PUBLIC_EXPOSED lists Content-Encoding:
Content-Length, Content-Encoding, Content-Range, Accept-Ranges, Content-Type, Content-Disposition, ETag, Retry-After, Link
Actual behavior
Content-Encoding is not CORS-safelisted, and the gateway does not expose it, so a cross-origin page reads null. Content-Length is exposed, but it counts the encoded bytes. A reader can't tell those bytes apart from the decoded body's length.
@decdn/client uses Content-Length as a lower bound on a body it can't hash. It skips that bound when Content-Encoding is set (decdn/sdk-typescript#21). On a cross-origin page it can't see the header, so:
- A small or incompressible body, whose encoded form is larger than the body, fails with a false
TRUNCATED. - A range the gateway answers whole (
200, e.g. a page a site rewrites) has its window andcontentRange.sizecomputed from the encoded length. DecdnResponse.contentLengthreports the encoded length.
Same-origin readers (a site page through /_decdn/) and Node aren't affected: they see every header.
Logs
n/a. The header list is at crates/cli/src/commands/gateway.rs (PUBLIC_EXPOSED), inserted in the public CORS headers (Access-Control-Expose-Headers).
Notes
- This is an SDK-observable gateway change. The SDK's contract suite (
test/contract/public.test.ts) can assertcontent-encodingis listed inaccess-control-expose-headers, and its fake gateway'sEXPOSEDmirrors the list. So the fix needs a matching sdk-typescript PR, anddecdn.gatewayFloorstays below it until it ships. appendix-gateway.mdshould list the header with the others, if it enumerates them.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
fix(client)!: route manifests by namespace, cut ranges answered whole…
test(contract): expect Content-Encoding among the exposed headers (#25)
test(contract): expect Content-Encoding among the exposed headers (#12)