Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

netlify dev returns 403 for static files in subdirectories on Windows (backslash in rewritten path)

Aperta Adatta ai principianti
#8,548 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Ramnath0521 ci sta già lavorando.

Dal 6/10/2026.

  • #8571 di @Ramnath0521 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, cli

Direzione di ricerca

Inizia da dist/utils/proxy.js, in getStatic, in particolare dalla chiamata a path.relative che costruisce l’URL riscritta. Riproduci il problema su Windows con una cartella di pubblicazione contenente css/styles.css e richiedilo tramite netlify dev. Il lavoro è completato quando i file statici annidati ricevono 200 tramite il proxy, come i file nella root e il comportamento su macOS/Linux.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

On Windows, netlify dev returns 403 Forbidden for any static file inside a subdirectory of the publish folder (e.g. /css/styles.css, /js/app.js). Files at the root of the publish folder (e.g. /index.html, /manifest.json) are served fine.

The cause is in getStatic in dist/utils/proxy.js (line 116 in 27.10.2):

return `/${path.relative(publicFolder, file)}`;

On Windows path.relative returns backslash-separated paths, so /css/styles.css becomes /css\styles.css. It is then passed through encodeURI (req.url = encodeURI(decodeURI(pathname)) + reqUrl.search) and forwarded as /css%5Cstyles.css, which @fastify/static in the static server rejects with:

{"statusCode":403,"error":"Forbidden","message":"Forbidden"}
Steps to reproduce
  1. On Windows, a site with publish = "src" and src/css/styles.css
  2. [dev] framework = "#static" (same result with netlify dev --dir src)
  3. netlify dev
  4. curl http://localhost:8888/css/styles.css → 403
  5. curl http://localhost:<static server port>/css/styles.css (bypassing the proxy) → 200
Expected behavior

/css/styles.css is served with 200 through the netlify dev proxy, as on macOS/Linux and in production.

Actual behavior

403 for every static file in a subdirectory, so pages load without their CSS/JS.

Notes
  • Windows-specific: on macOS/Linux path.relative returns forward slashes, so the path is correct. Production (Netlify CDN) is not affected.
  • Possible fix: normalize the separator, e.g.
    return `/${path.relative(publicFolder, file).split(path.sep).join('/')}`;
Environment
  • netlify-cli 27.10.2
  • Node.js v24.15.0
  • Windows 11 (10.0.26200)
Lingua principale
TypeScript
Stelle
1.9k
Fork
478
Merge medio
1g 18h
PR unite (30g)
37

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di netlify/cli

Tutte le issue di netlify/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.