CORS localhost requests are considered invalid host and get blocked
Maintainer antworten meist innerhalb von 1 Tag
@Jeston10 arbeitet bereits daran.
Seit 25.1.2026.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, node.js, webpack
Rechercherichtung
Beginne in lib/Server.js bei der cross-origin-header-check-Middleware und verfolge anschließend isValidHost, isHostAllowed und den im Issue erwähnten validateHost-Pfad. Verwende die verlinkte minimale Reproduktion und deren README, um das Verhalten zu überprüfen; als erledigt gilt die Aufgabe, wenn localhost-Anfragen aus dem no-cors-Cross-Site-iframe erfolgreich sind, ohne localhost ausdrücklich zu allowedHosts hinzuzufügen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug Description
If webpack-dev-server gets "no-cors cross-site" requests, localhost is not considered an allowed host and a 403 Forbidden is returned.
By explicitly adding allowedHosts: ['localhost'] to the webpack config, the bug is circumvented.
Link to Minimal Reproduction and step to reproduce
In the following project, an iframe is constructed from a blob HTML string. The iframe contains a script tag which refers to a resource URL which is hosted by webpack dev server.
https://github.com/RedMser/bug-webpack-dev-server-corb
See the readme in the repo for reproduction steps.
Expected Behavior
Requests to localhost should succeed, even if they originate from a "no-cors cross-site" context.
Actual Behavior
The request fails with a 403 Forbidden response.
Environment
System:
OS: Windows 11 10.0.26100
CPU: (4) x64 Intel(R) Xeon(R) Platinum 8462Y+
Memory: 2.84 GB / 19.00 GB
Binaries:
Node: 24.11.1 - C:\nvm4w\nodejs\node.EXE
npm: 11.6.2 - C:\nvm4w\nodejs\npm.CMD
Browsers:
Chrome: 141.0.7390.123
Edge: Chromium (141.0.3537.57)
Firefox: 140.5.0 - C:\Program Files\Mozilla Firefox\firefox.exe
Internet Explorer: 11.0.26100.1882
Packages:
webpack: ^5.102.1 => 5.102.1
webpack-cli: ^6.0.1 => 6.0.1
webpack-dev-server: ^5.2.2 => 5.2.2
Is this a regression?
None
Last Working Version
No response
Additional Context
Responsible is the cross-origin-header-check middleware.
In particular, isValidHost calls isHostAllowed which contains following comment:
According to this outdated comment, localhost should be always allowed, but there is no code that actually ensures this here!
isValidHost does check for localhost among other things, but validateHost == false in this particular instance.
It might be caused by the refactor in 6045b1e9d63078fb24cac52eb361b7356944cddd but I did not investigate further. This used to work in the past so it's likely a regression, let me know if more info is needed.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 7.9k
- Forks
- 1.5k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesEvtl. wieder frei @AnumanyaJaiswal hat das vor 35 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
webpack/webpack-dev-server#5716 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
webpack/webpack-dev-server#5679 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Webpack dev server URL should be displayed more prominentlyEvtl. vergeben @snitin315 hat das vor 805 Tagen übernommen. Offen
webpack/webpack-dev-server#4907 · 7 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
webpack/webpack-dev-server#4540 · 9 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
webpack/webpack-dev-server#4378 · 29 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in webpack/webpack-dev-server
Ähnliche Issues
-
[bug] 提瓦特记事本原石检测框宽度较窄Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
babalae/bettergi-scripts-list#3905 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 87/100
dedicatedcode/reitti#1445 ·
Maintainer antworten meist innerhalb von 1 Tag
-
New tool: Uncle DeskEvtl. vergeben @github-actions hat das heute übernommen. Offensubmission triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
kausalflow/tools#384 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
-
area: css
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag