CORS localhost requests are considered invalid host and get blocked
Maintainers usually reply within 1 day
@Jeston10 is already working on this.
Since Jan 25, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript, node.js, webpack
Research direction
Start in lib/Server.js at the cross-origin-header-check middleware, then trace isValidHost, isHostAllowed, and the validateHost path mentioned in the issue. Use the linked minimal reproduction and its README to verify the behavior; done means localhost requests from the no-cors cross-site iframe succeed without explicitly adding localhost to allowedHosts.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- JavaScript
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- No 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 webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesMay be free again @AnumanyaJaiswal claimed this 35 days ago, and no pull request is open. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
webpack/webpack-dev-server#5716 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
webpack/webpack-dev-server#5679 · 3 comments ·
Maintainers usually reply within 1 day
-
Webpack dev server URL should be displayed more prominentlyPossibly taken @snitin315 claimed this 805 days ago. Open
webpack/webpack-dev-server#4907 · 7 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
webpack/webpack-dev-server#4540 · 9 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
webpack/webpack-dev-server#4378 · 29 comments · 3 reactions ·
Maintainers usually reply within 1 day
All issues in webpack/webpack-dev-server
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
babalae/bettergi-scripts-list#3905 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Open
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
dedicatedcode/reitti#1445 ·
Maintainers usually reply within 1 day
-
New tool: Uncle DeskPossibly taken @github-actions claimed this today. Opensubmission triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
kausalflow/tools#384 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
area: css
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day