我想通过我的Hubconnection构建器将标头传递给我的signalrHub。 换句话说,我该如何使用打字稿来做到这一点。
这是我拥有的C#实现:
connection = new HubConnectionBuilder()
.WithUrl("https://localhost:53251" + "/simpleHub", options =>
{
//set the header
options.Headers.Add("Device-ID", deviceID);
})
.Build();
如何使用Typescript客户端执行相同操作? 我尝试了网上发现的几件事,最新的是:
this._hubConnection = new HubConnectionBuilder()
.withUrl("https://localhost:53251" + "/simpleHub?Device-ID=fc8dsc72f-1456-4bc2-b1ea-ac34b9c3559e", {
})
.configureLogging(LogLevel.Debug)
.withAutomaticReconnect()
.build();
但是以这种方式传递标头会导致服务器无法接收标头。请问有人有解决方案吗?请。