[vite-plugin] Requests forwarded to the Worker gain `sec-fetch-mode: cors` and `accept-language: *`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
- #17194 di @exKAZUu — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript, vite
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 4.7k
- Fork
- 1.7k
- Merge medio
- 1g 22h
- PR unite (30g)
- 282
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloudflare/workers-sdk
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
cloudflare/workers-sdk#17215 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
cloudflare/workers-sdk#17189 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cloudflare/workers-sdk#17187 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
cloudflare/workers-sdk#17175 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
cloudflare/workers-sdk#17174 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cloudflare/workers-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
earendil-works/pi#12615 ·
I maintainer di solito rispondono entro 1 giorno
-
My Caps shows "Shared" on private Caps that were never sharedForse già presa @AksharP5 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CapSoftware/Cap#4569 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
OHDSI/Data2Evidence#3749 ·
I maintainer di solito rispondono entro 4 giorni
-
PWA: Unique Page TitlesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
I maintainer di solito rispondono entro 2 giorni