dotnet-serve icon indicating copy to clipboard operation
dotnet-serve copied to clipboard

System.ArgumentException: An item with the same key has already been added. Key: Cross-Origin-Embedder-Policy

Open Jasonlhy opened this issue 2 years ago • 2 comments

Describe the bug I want to add two headers so that SharedArrayBuffer can be enabled on the JavaScript side so I set up the .netconfig file as follow:

[serve]
    header = Cross-Origin-Embedder-Policy: require-corp
    header = Cross-Origin-Opener-Policy: same-origin

Sometimes it works, sometimes it doesn't work. Error message: System.ArgumentException: An item with the same key has already been added. Key: Cross-Origin-Embedder-Policy

To Reproduce Steps to reproduce the behavior: Environment: Ubuntu 22

  1. Run dotnet serve
  2. Or run dotnet serve --headers "Cross-Origin-Embedder-Policy:require-corp" --headers "Cross-Origin-Opener-Policy:same-origin"

You can just test this repo in Github codespace: https://github.com/Jasonlhy/emcc-playground

Environment Windows 11

  1. Run dotnet serve is fine without facing any issues, it can also add the two headers
  2. Run dotnet serve --headers "Cross-Origin-Embedder-Policy:require-corp" --headers "Cross-Origin-Opener-Policy:same-origin" will face the same issue

Workaround Run dotnet serve .netconfig

Expected behavior Two headers should be added successfully without facing any error

Screenshots image

Jasonlhy avatar Dec 29 '22 23:12 Jasonlhy

None of the code in this project adds this header. Have you checked if there is something happening automatically in the ASP.NET Core framework itself? I did a quick search and see a few issues mentioning this header, https://github.com/dotnet/aspnetcore/search?q=Cross-Origin-Embedder-Policy&type=issues.

natemcmaster avatar Jan 16 '23 20:01 natemcmaster

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

github-actions[bot] avatar Jan 17 '24 01:01 github-actions[bot]

Closing due to inactivity. If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.

github-actions[bot] avatar Feb 01 '24 01:02 github-actions[bot]