Skip to content
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

headers for dev-server not working anymore after upgrade from angular 16 to 17 #27464

Closed
piu130 opened this issue Apr 12, 2024 · 9 comments · Fixed by #27517
Closed

headers for dev-server not working anymore after upgrade from angular 16 to 17 #27464

piu130 opened this issue Apr 12, 2024 · 9 comments · Fixed by #27517

Comments

@piu130
Copy link

piu130 commented Apr 12, 2024

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

I've created a new angular 17 app with ng new angular-tour-of-heroes.
After adding custom headers in angular.json:

"serve" {
  "builder": "@angular-devkit/build-angular:dev-server",
  "options": {
    "headers": {
      "Cross-Origin-Opener-Policy": "same-origin",
      "Cross-Origin-Embedder-Policy": "require-corp"
    }
  }
}

they are not present in the initial localhost (index.html) request. All subsequent requests contains the headers.
When creating a new angular 16 app and adding the same config it works for the initial request as well.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

In the real code we see the error `Uncaught ReferenceError: SharedArrayBuffer is not defined` due to the missing headers.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.4
Node: 20.12.1
Package Manager: npm 10.5.0
OS: win32 x64

Angular: 17.3.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.4
@angular-devkit/build-angular   17.3.4
@angular-devkit/core            17.3.4
@angular-devkit/schematics      17.3.4
@schematics/angular             17.3.4
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.4

Anything else?

No response

@NetWin
Copy link

NetWin commented Apr 14, 2024

I just noticed the same / a similar issue. These headers are also not available for /media files (i.e. files embedded / referenced from css files)

Using the "old" browser builder with a random custom header for demo purposes,

results in these response headers (i simply @import'ed the primeicons css file in my styles.scss):

But after updating (and switching to the application builder) the custom header is gone.


Additionally there is no Access-Control-Allow-Origin header anymore which is another problem for me. But that's not part of this Github issue

@PJozeph
Copy link

PJozeph commented Apr 23, 2024

same issue here

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 23, 2024
…nd HTML page

Headers were not configured correctly.

Closes angular#27464
@alan-agius4 alan-agius4 added severity3: broken freq1: low Only reported by a handful of users who observe it rarely labels Apr 23, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 23, 2024
…ia resources and HTML page

Headers were not configured correctly.

Closes angular#27464
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Apr 23, 2024
…dia resources and HTML page

Headers were not configured correctly.

Closes angular#27464
alan-agius4 added a commit that referenced this issue Apr 23, 2024
…nd HTML page

Headers were not configured correctly.

Closes #27464
alan-agius4 added a commit that referenced this issue Apr 23, 2024
…dia resources and HTML page

Headers were not configured correctly.

Closes #27464
@PJozeph
Copy link

PJozeph commented Apr 24, 2024

so this is fixed ? if yes in which version ?

@alan-agius4
Copy link
Collaborator

Yes, it be released on NPM later on today.

@PJozeph
Copy link

PJozeph commented Apr 26, 2024

@alan-agius4
For mw it work only locally, but not on PROD !
Is this the correct way of config ?
image

@alan-agius4
Copy link
Collaborator

@PJozeph, for the production server you need to configure your production server which settings will vary based on which server you are using.

The settings in angular.json are only apply to the development server.

@alan-agius4
Copy link
Collaborator

@PJozeph, the production section solely effects the development server when executed with the production configuration ie: ng serve --configuration=production. In this scenario, the headers configuration is redundant, as it duplicates the one configured in the base options.

These settings do not affect your production server, as the configuration of the production server is outside the Angular CLI's.

@PJozeph
Copy link

PJozeph commented Apr 26, 2024

@alan-agius4 I am really appreciate your help, thank you !

This is how I fixed the issue on PROD !

image

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants