Repository navigation
fix(cloudflare/workers): send _redirects/_headers contents to Cloudflare - #928
Merged
Merged
Conversation
The special asset files were read from the assets directory, excluded from the upload manifest, and folded into the change-detection hash — but their contents were never sent in the script metadata, so redirect and header rules silently never applied. - readAssets now folds the file contents into the returned config (metadata.assets.config._redirects/_headers, matching wrangler) - the prebuilt-hash keep-assets path re-reads just the two files so a no-op deploy doesn't wipe the rules - local dev passes the file contents to the runtime for parity Fixes #927 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/6005f3f@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/6005f3f@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/6005f3f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #927.
readAssetsread_redirects/_headersfrom the assets directory, excluded them from the upload manifest, and folded their contents into the change-detection hash — but never sent them to Cloudflare, so redirect/header rules were silently dropped (requests 404'd or fell through to the worker).The distilled
PutScriptRequest.metadata.assets.configtype already carriesheaders/redirects(wire-encoded as_headers/_redirects), so no SDK change was needed — only the wiring:readAssetsnow folds the file contents into the returnedconfig, mirroring wrangler'smetadata.assets.config._redirects/_headers. Explicitheaders/redirectsprops still win. The merge happens after hashing, so existing asset hashes are unchanged (no spurious redeploys).prebuiltAssets.skip) never walks the directory, but the PUT replaces the asset config wholesale — it now re-reads just the two files so a no-op deploy doesn't wipe the rules:LocalWorkerProviderreads the same files and passes their contents to the local runtime, which already parsesheaders/redirectsstrings.Live test (
test/Cloudflare/Workers/AssetsConfigFiles.test.ts) deploys a worker with a_redirects+_headersfixture and asserts over HTTP: the 301 applies, the header applies,_redirectsitself isn't served, editing_redirectsdeploys the new rules, and the rules survive a keep-assets (hash-match skip) deploy.🤖 Generated with Claude Code