Skip to content

Commit

Permalink
Disable SignalR credentials and supplied access token on web client s…
Browse files Browse the repository at this point in the history
…ignalR side and it works!
  • Loading branch information
bleunguts committed Jan 26, 2024
1 parent 2edb887 commit 3de2693
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion ProjectX.GatewayAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapControllers();
if (env.IsProduction())
{
// azure signalR not supported yet, don't run in prod
endpoints.MapHub<StreamHub>("/streamHub");
}
else
Expand Down
10 changes: 7 additions & 3 deletions Web/src/components/layout/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const backendServer = `https://projectxgatewayapi-app-20231130.icybay-6c4fad7d.
//const backendServer = `https://localhost:8081`;

const connection = new signalR.HubConnectionBuilder()
.withUrl(`${backendServer}/streamHub`)
.withUrl(`${backendServer}/streamHub`,
{
accessTokenFactory: () => 'zpq+oW5R6HtWi0Or1XAI0BJcLHTaXOlQHLhRHo7A8IQ=',
withCredentials: false
})
.configureLogging(signalR.LogLevel.Information)
.build();

Expand All @@ -19,10 +23,10 @@ async function startHubConnection() {
await connection.start();
console.log("SignalR Connected.");
} catch (err) {
console.log(err);
console.log(`SignalR Connection error: {err}`);
setTimeout(startHubConnection, 5000);
}
};
}

connection.onclose(async () => {
await startHubConnection();
Expand Down

0 comments on commit 3de2693

Please sign in to comment.