Skip to content

fix(@angular/build): allow configuring Access-Control-Allow-Origin via headers option#32976

Merged
alan-agius4 merged 2 commits intoangular:mainfrom
alan-agius4:cors-setting
Apr 10, 2026
Merged

fix(@angular/build): allow configuring Access-Control-Allow-Origin via headers option#32976
alan-agius4 merged 2 commits intoangular:mainfrom
alan-agius4:cors-setting

Conversation

@alan-agius4
Copy link
Copy Markdown
Collaborator

Removes the default Vite CORS origin: true configuration, allowing custom Access-Control-Allow-Origin header configurations to take effect when using the development server.

BREAKING CHANGE: The development server (ng serve) no longer automatically mirrors the request origin in the Access-Control-Allow-Origin response header by default. If your application relies on cross-origin requests during local development, you must now explicitly configure the required CORS headers using the headers option in your angular.json configuration.

Fixes #32923

…a headers option

Removes the default Vite CORS origin: true configuration, allowing custom Access-Control-Allow-Origin header configurations to take effect when using the development server.

BREAKING CHANGE: The development server (ng serve) no longer automatically mirrors the request origin in the Access-Control-Allow-Origin response header by default. If your application relies on cross-origin requests during local development, you must now explicitly configure the required CORS headers using the headers option in your angular.json configuration.

Fixes angular#32923
@alan-agius4 alan-agius4 requested review from clydin and dgp1130 April 9, 2026 14:39
@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Apr 9, 2026
@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change area: @angular/build labels Apr 9, 2026
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 9, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the Angular dev server's Vite configuration to remove the default Access-Control-Allow-Origin: true setting, meaning the Access-Control-Allow-Origin header will no longer be automatically mirrored. A new test case was added to verify that when the header is explicitly configured, it is correctly applied. The reviewer suggests adding another test to explicitly confirm that the Access-Control-Allow-Origin header is not set by default when no headers option is provided, to fully cover the breaking change in behavior.

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 10, 2026
@alan-agius4 alan-agius4 removed the request for review from clydin April 10, 2026 10:17
@alan-agius4 alan-agius4 merged commit b85ec67 into angular:main Apr 10, 2026
36 checks passed
@alan-agius4
Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4 alan-agius4 deleted the cors-setting branch April 10, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build detected: breaking change PR contains a commit with a breaking change target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permissive CORS policy in Dev Server enables cross-origin source code exfiltration

2 participants