[vite-plugin] Requests forwarded to the Worker gain `sec-fetch-mode: cors` and `accept-language: *`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #17194 by @exKAZUu — closed without merging
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript, vite
Research direction
Start by tracing how the Vite plugin forwards incoming requests to the Worker during vite dev and vite preview, then inspect the use of undici's fetch described in the report. Reproduce with the three-file example and the supplied curl command, comparing the headers received by the Worker with wrangler dev. Done when absent sec-fetch-mode and accept-language headers stay absent in both Vite modes.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
System:
OS: macOS 27.2.1
Binaries:
Node: 26.13.1
npm: 11.20.0
bun: 1.4.5
npmPackages:
@cloudflare/vite-plugin: 1.70.2 (same result with 2.0.0-rc.5)
wrangler: 4.168.0
vite: 7
Please provide a link to a minimal reproduction
Inline below (three files).
Describe the Bug
Under vite dev and vite preview, a request that carries no sec-fetch-mode and no accept-language header reaches the Worker with sec-fetch-mode: cors and accept-language: *. wrangler dev passes the same request through without them. The plugin forwards the incoming request with undici's fetch, which fills in both headers when they are absent.
This changes what a Worker sees for non-browser clients (curl, server-to-server calls, Playwright's request API). For example, a CSRF check that enforces an origin only when fetch-metadata headers are present rejects, locally, requests it accepts when deployed.
vite.config.ts
import { cloudflare } from '@cloudflare/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({ plugins: [cloudflare()] });
wrangler.jsonc
{ "name": "repro", "main": "src/index.ts", "compatibility_date": "2026-10-01" }
src/index.ts
export default {
fetch(request: Request): Response {
return Response.json(Object.fromEntries(request.headers));
},
};
Steps: start the server, then curl -s -X POST -d a http://localhost:<port>/x.
Header names the Worker receives:
wrangler dev:accept,accept-encoding,cf-connecting-ip,content-length,content-type,host,user-agentvite devandvite preview: the above plusaccept-language(*),sec-fetch-mode(cors),connection,x-forwarded-host
Expected: the Worker receives sec-fetch-mode and accept-language only when the client sent them, as with wrangler dev.
Please provide any relevant error logs
None.
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
cloudflare/workers-sdk#17175 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days