Skip to content

Conversation

@jamesopstad
Copy link
Contributor

@jamesopstad jamesopstad commented Oct 30, 2025

Fixes #000.

Switch all instances of miniflare.getWorker() followed by worker.fetch() to use miniflare.dispatchFetch(). This means that the Vite plugin now emulates Cloudflare's response encoding in the same way as Wrangler.


  • Tests
    • Tests included
    • Tests not necessary because: covered by existing tests
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal change
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a Wrangler change

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

🦋 Changeset detected

Latest commit: 9077c9e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 30, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11137

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11137

miniflare

npm i https://pkg.pr.new/miniflare@11137

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11137

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11137

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11137

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11137

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11137

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11137

wrangler

npm i https://pkg.pr.new/wrangler@11137

commit: 9077c9e

@jamesopstad jamesopstad marked this pull request as ready for review October 30, 2025 17:33
@jamesopstad jamesopstad requested a review from a team October 30, 2025 17:33
@jamesopstad jamesopstad requested a review from a team as a code owner October 30, 2025 17:33
@jamesopstad jamesopstad force-pushed the james/use-dispatch-fetch branch from 0b59ade to be441f1 Compare October 30, 2025 17:57
Comment on lines -56 to -66
override async unstable_canFetch(request: Request) {
// the 'sec-fetch-mode: navigate' header is stripped by something on its way into this worker
// so we restore it from 'x-mf-sec-fetch-mode'
const secFetchMode = request.headers.get("X-Mf-Sec-Fetch-Mode");

if (secFetchMode) {
request.headers.set("Sec-Fetch-Mode", secFetchMode);
}

return await super.unstable_canFetch(request);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed because it's handled in Miniflare.

@penalosa
Copy link
Contributor

Can we also remove the custom cdn-cgi triggers handling?

@jamesopstad
Copy link
Contributor Author

Can we also remove the custom cdn-cgi triggers handling?

We can remove the extra plugin and put the trigger handling in the preMiddleware (planning to do that in a follow up) but it will still need the ROUTE_OVERRIDE header to go directly to the User Worker.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Oct 31, 2025
@jamesopstad jamesopstad force-pushed the james/use-dispatch-fetch branch from be441f1 to 06640fa Compare October 31, 2025 14:25
@jamesopstad jamesopstad force-pushed the james/use-dispatch-fetch branch from 06640fa to 9077c9e Compare October 31, 2025 15:47
@jamesopstad jamesopstad merged commit c2a63ab into main Oct 31, 2025
65 of 72 checks passed
@jamesopstad jamesopstad deleted the james/use-dispatch-fetch branch October 31, 2025 19:33
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants