You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CORS localhost requests are considered invalid host and get blocked #5603
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.
According to this outdated comment, localhost should be always allowed, but there is no code that actually ensures this here! isValidHostdoes check for localhost among other things, but validateHost == false in this particular instance.
It might be caused by the refactor in 6045b1e 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.
@alexander-akait Sir I have raised a PR, If possible I would like it to be reviewed. I added a test case for the issue and removed the test case after testing if it works. I would like to know if I should include test case again. Thank you so much Sir.
Activity
shubham220420 commentedon Nov 12, 2025
Hey I want to work on this issue can you assign it to me?
alexander-akait commentedon Nov 12, 2025
@RedMser We should fix commens and you should use
allowedHosts: "all"or provide real hosts, that is expected to prevent - GHSA-4v9v-hfq4-rm2v and GHSA-9jgg-88mc-972hMuskan-shukla910 commentedon Jan 8, 2026
Hey sir I want to work on this issue can you assign it to me?
Jeston10 commentedon Jan 25, 2026
@Branch Moderators, I would like to work on this issue. Can i please get assigned for this.
fix: always allow localhost in cross-origin no-cors requests
Jeston10 commentedon Jan 25, 2026
@alexander-akait Sir I have raised a PR, If possible I would like it to be reviewed. I added a test case for the issue and removed the test case after testing if it works. I would like to know if I should include test case again. Thank you so much Sir.