我正在使用来自This npm package的@ aspnet / signalr官方Javascript客户端
我想知道是否有方法将Header配置添加到客户端连接头
我如何建立连接
let connection = new signalR.HubConnectionBuilder()
.withUrl(
"https://some.signalr-host.com"
)
.build();
做了一些研究后更新
看起来像signalR js / ts客户端库不支持添加自定义标头
因此,我们的解决方案是通过查询字符串发送参数,并使服务器API支持它
由于信号R URL连接没有显示在地址栏中,所以它有点安全
EG
const connection = new HubConnectionBuilder()
.withUrl(
`${signalrUrl}&${key}=${value}`)
.build();