-
Notifications
You must be signed in to change notification settings - Fork 12k
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
CORS pre-flight requests return HTTP 404 on assets served by dev-server #23639
Labels
area: @angular-devkit/build-angular
devkit/build-angular:dev-server
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
type: bug/fix
Comments
This appears to be a defect in webpack-dev-server. |
alan-agius4
added
type: bug/fix
area: @angular-devkit/build-angular
devkit/build-angular:dev-server
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
labels
Jul 27, 2022
alan-agius4
added a commit
to alan-agius4/angular-cli
that referenced
this issue
Jul 27, 2022
…quests With this commit, we add a middleware that handles preflight requests as currently responses for this type of requests returning 404. This is a temporary workaround until this issue is fixed upstream. See: webpack/webpack-dev-server#4180 Closes angular#23639
alan-agius4
added a commit
to alan-agius4/angular-cli
that referenced
this issue
Jul 27, 2022
…quests With this commit, we add a middleware that handles preflight requests as currently responses for this type of requests returning 404. This is a temporary workaround until this issue is fixed upstream. See: webpack/webpack-dev-server#4180 Closes angular#23639
alan-agius4
added a commit
to alan-agius4/angular-cli
that referenced
this issue
Aug 2, 2022
…quests With this commit, we add a middleware that handles preflight requests as currently responses for this type of requests returning 404. This is a temporary workaround until this issue is fixed upstream. See: webpack/webpack-dev-server#4180 Closes angular#23639
dgp1130
pushed a commit
that referenced
this issue
Aug 2, 2022
…quests With this commit, we add a middleware that handles preflight requests as currently responses for this type of requests returning 404. This is a temporary workaround until this issue is fixed upstream. See: webpack/webpack-dev-server#4180 Closes #23639
dgp1130
pushed a commit
that referenced
this issue
Aug 2, 2022
…quests With this commit, we add a middleware that handles preflight requests as currently responses for this type of requests returning 404. This is a temporary workaround until this issue is fixed upstream. See: webpack/webpack-dev-server#4180 Closes #23639 (cherry picked from commit b4a1b0f)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area: @angular-devkit/build-angular
devkit/build-angular:dev-server
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
type: bug/fix
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, it seem to have been introduced after Angular 12, as I was able to reproduce it in Angular 14 and others have encountered the problem in Angular 13.
Description
When using the standard dev-server, CORS pre-flight requests for assets fail.
This is usually not an issue since most of the time your app and assets are served from the same origin (thus there are no CORS pre-flight requests) but I work with single-spa where my app run on a origin (for example: my-single-spa.app) while my dev server is running on a different origin (localhost:4202), which is frequent when developing web apps using single-spa.
🔬 Minimal Reproduction
I created a simple Angular 14 app that request a JSON file using
HttpClient
and served using theng serve --port 4202 [--disable-host-check]
command.Then when opening the app in the browser, the json is successfully loaded as there are no CORS at play since, as I said earlier, the app and the assets are served from the same origin.
But if you do an OPTIONS request like a browser would do for preflight CORS requests, the dev server returns an HTTP 404:
Note that it also fails if you add
Origin: http://localhost:4202
as a header or if you add the--disable-host-check
flag tong serve
.If you just GET the file, it exists:
You can find a sample project to reproduce the issue here. The branch is
standard-webpack
, please discardmain
andno-custom
as I previously thought the issue lied in just-jeb/angular-builders.🌍 Your Environment
The text was updated successfully, but these errors were encountered: