Skip to content

webpack-dev-server 5.2.1 needs resources to be crossorigin in default setups #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fish-face opened this issue Apr 3, 2025 · 1 comment

Comments

@fish-face
Copy link

See comment (and further discussion) here.

Version 5.2.1 of the dev server introduced a very strict change to how it deals with requests in the normal setup, where you have HTML served from one origin (say, localhost:8080) and webpack serving from another (say, localhost:4000). In this case, all such requests will be blocked if the resource does not have the crossorigin attribute.

Ordinarily, such a cross-origin request would be fine; the browser sends the header sec-fetch-mode: no-cors to inform the server that it is not using CORS and, as long as the request is reasonably safe (e.g. a GET request for a stylesheet) the server will respond no matter the cross-origin status. Enforcement of cross-origin policy is left as a matter for the browser.

In webpack-dev-server 5.2.1 the maintainers implemented some enforcement of CORS in the server by returning 403 for all cross-origin requests that use this mode. Adding the crossorigin attribute causes the browser to engage its CORS enforcement, and the dev server allows this.

@fjsj
Copy link
Member

fjsj commented Apr 14, 2025

@fish-face thanks for reporting this issue! @rvlb @pamella @hugobessa could you please check? This may break newer versions of webpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants