Repository navigation
Labels
angular/build:dev-serverarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Description
Command
serve
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
@angular-devkit/build-angular 19.1.4
Description
Starting with Angular 19.1.5, when running the development server using ng serve, the Access-Control-Allow-Origin header is no longer included in responses when accessing assets. In version 19.1.4, this header was still being sent with the value '*'.
This affects cross-origin requests to static assets served by the development server.
Minimal Reproduction
Repository for minimal reproduction:
[Link to Git Repository]
Steps to reproduce:
- Clone repository and install dependencies:
git clone https://github.com/vkennke/angular-cors.git
cd angular-cors
npm install- Start dev server:
ng serve- Access http://localhost:4200/assets/test.txt and check response headers
Expected behavior:
Response headers include Access-Control-Allow-Origin: *
Actual behavior:
Access-Control-Allow-Origin header is missing from response
To verify this is a regression:
- Edit package.json to set @angular-devkit/build-angular to 19.1.4:
"@angular-devkit/build-angular": "19.1.4"- Repeat steps 2-3
- Observe that the Access-Control-Allow-Origin: * header is present
Exception or Error
No error is thrown, but the missing header prevents cross-origin requests from succeeding.
Your Environment
Angular CLI: 19.1.5
Node: 20.18.0
Package Manager: npm 10.8.2
OS: win32 x64
Angular: 19.1.4
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1901.5
@angular-devkit/build-angular 19.1.5
@angular-devkit/core 19.1.5
@angular-devkit/schematics 19.1.5
@angular/cli 19.1.5
@schematics/angular 19.1.5
rxjs 7.8.1
typescript 5.7.3
zone.js 0.15.0
Anything else relevant?
No response
Reacted by akop, Jonas Schmid, Jeri Peier and Konstantin Genov
Metadata
Metadata
Assignees
Labels
angular/build:dev-serverarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Activity
[-]Access-Control-Allow-Origin header missing in dev server for assets starting with Angular 19.1.5[/-][+]Access-Control-Allow-Origin header missing in dev server for assets[/+]alan-agius4 commentedon Feb 10, 2025
Can you explain why you need this header? If you're accessing resources from a different host, this behavior is expected. For more details, see: #29471.
AndreKoepke commentedon Feb 10, 2025
Longer answer
In our case: We have a multi-frontend-system. The "main"-system runs somewhere in cloud (for example under "example.com") and loads its configured subsystems from various different domains ("exampleA.com", "exampleB.com", and so on).
Each subsystem has a defined entrypoint - the asset-file "manifest.json". Have a look at scion-workbench for more details.
For developing-purposes it is necessary that we can use the "manifest.json" from our local environment. We can say at domain "example.com" that one manifest can be found at localhost. Then the system tries to load the "localhost:4200/assets/manifest.json" file while the webpage is running under "example.com".
I will have a look at #29471 tomorrow. Maybe it solves our problems.
For us, it was a big surprise that jumping to the next patch release causing these kinds of troubles.
vkennke commentedon Feb 11, 2025
Patch versions should never introduce breaking changes.
Our workaround is to set the header manually.
AndreKoepke commentedon Feb 11, 2025
I tried to set
but it won't work. I got a warning "The "allowedHosts" option will not be used because it is not supported by the "@angular-devkit/build-angular:application" builder.", is it already released?
The workaround of @vkennke works well.
alan-agius4 commentedon Feb 11, 2025
The warning is no longer relevant and should be removed, setting the
allowedHosts. I did some further digging and indeed theAccess-Control-Allow-Originis not added in this case.@vkennke, you're right that patch updates should avoid breaking changes. However, in this case, it was necessary to address a security vulnerability in Vite.
fix(@angular/build): configure Vite CORS option
fix(@angular/build): configure Vite CORS option
fix(@angular/build): configure Vite CORS option
fix(@angular/build): configure Vite CORS option
fix(@angular/build): configure Vite CORS option
AndreKoepke commentedon Feb 13, 2025
Confirmed. In 19.1.7 is all fine again. Thanks @alan-agius4. 👍
angular-automatic-lock-bot commentedon Mar 16, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.