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

SignalR typescript client fails to add custom headers #37700

Closed
fallenwood opened this issue Oct 20, 2021 · 2 comments
Closed

SignalR typescript client fails to add custom headers #37700

fallenwood opened this issue Oct 20, 2021 · 2 comments
Labels
area-signalr Includes: SignalR clients and servers ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@fallenwood
Copy link
Member

Describe the bug

I try to add custom headers when creating a new SignalR connection, but it does not show in devtools.

To Reproduce

Here is the link to the demo https://github.com/fallenwood/signalr-header-report-demo
I have added a X-Test-Token header but it is missing.
Here is the snapshot
Snipaste_2021-10-20_15-33-52

Exceptions (if any)

N/A

Further technical details

  • ASP.NET Core version: net5.0
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: Visual Studio/Command Line
  • Include the output of dotnet --info:
dotnet --info Output
> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.402
 Commit:    e9d3381880

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.402\

Host (useful for support):
  Version: 5.0.11
  Commit:  f431858f8b

.NET SDKs installed:
  3.1.414 [C:\Program Files\dotnet\sdk]
  5.0.401 [C:\Program Files\dotnet\sdk]
  5.0.402 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
@javiercn javiercn added the area-signalr Includes: SignalR clients and servers label Oct 20, 2021
@BrennanConroy
Copy link
Member

You cannot set headers on Websocket requests in the browser. The docs mention this for the headers property
https://docs.microsoft.com/aspnet/core/signalr/configuration?view=aspnetcore-5.0&tabs=javascript#configure-client-options-1

@BrennanConroy BrennanConroy added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Oct 20, 2021
@ghost ghost added the Status: Resolved label Oct 20, 2021
@fallenwood
Copy link
Member Author

Okay, thanks for the answer, then I will use long polling instead of websockets.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants