Hello,
I used signalr to communicate the server to client application.
I have an issue when I deployed on the server.
The request used for the negotiation is empty (see print screen and in the code is connect.start()). But the url is not empty when I put the debug information. You can see in the picture baseurl contain the value in the configuration string. :
The code to start the connexion.
const options: IHttpConnectionOptions = {
accessTokenFactory: async () => {
const request = {...loginRequest,
account: accounts[0]};
var token = await instance.acquireTokenSilent(request);
return token.accessToken;
},
transport: HttpTransportType.WebSockets
};
const connect = new HubConnectionBuilder()
.withUrl(process.env.NEXT_PUBLIC_SIGNALR_URL!,options)
.configureLogging(LogLevel.Debug)
.withAutomaticReconnect()
.build();
console.log("signalR connection")
console.log("baseUrl:", connection.baseUrl)
if(!connect .baseUrl)
return;
connect
.start()
.then(() => {
connection.on("target", (message) => {
let obj: T = JSON.parse(message);
setMessage(obj);
});
})
.catch((error) => console.log("signalR:", error));
The client application is done in react. So When I launch the application locally, the negotiate step can be done with the correct url.
I configure the CORS to open the url. The configuration in Azure contains the url because I put the url in the console log.