Honor assetConfig.headers/redirects when no on-disk _headers/_redirects file is present#13927
Conversation
|
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
To me, it feels like the programmatic API should take priority over the |
petebacondarwin
left a comment
There was a problem hiding this comment.
Hi @allsey87 - thanks for putting up this PR. Please can you read https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md and add the necessary tests, changeset and PR description in order for us to consider this PR.
I also agree that programmatic should take precedence.
Describe your change
When a Miniflare consumer provides headers/redirects via the programmatic API:
…the values are silently discarded today.
AssetsOptionsSchemaadvertisesassetConfig.headersandassetConfig.redirectsas part of the API surface (seepackages/miniflare/src/plugins/assets/schema.ts), butpackages/miniflare/src/plugins/assets/index.tsoverwrites them unconditionally withparsedHeaders/parsedRedirects, which are populated only from the on-disk_headers/_redirectsfiles. When no file is present, the user-supplied config is replaced withundefined:This change keeps file-based config as the source of truth when a
_headers/_redirectsfile exists, and falls back tooptions.assets.assetConfig.headers/.redirectsotherwise. The schema already requires the programmatic value to be in the parsed shape (HeadersSchema/RedirectsSchema), so no extra parsing is needed.Concrete impact: COOP/COEP headers configured programmatically now actually reach the browser, so
crossOriginIsolatedis true andSharedArrayBuffertransfers across workers succeed.