From 17330fc10483fca1bf43e7ce74d0fe355912c3e6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 10 Jul 2025 15:57:00 +0800 Subject: [PATCH] :bug: Fixes for websocket --- DysonNetwork.Sphere/Connection/ClientTypeMiddleware.cs | 2 +- DysonNetwork.Sphere/Connection/WebSocketController.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DysonNetwork.Sphere/Connection/ClientTypeMiddleware.cs b/DysonNetwork.Sphere/Connection/ClientTypeMiddleware.cs index 937efb5..cf0cbc3 100644 --- a/DysonNetwork.Sphere/Connection/ClientTypeMiddleware.cs +++ b/DysonNetwork.Sphere/Connection/ClientTypeMiddleware.cs @@ -33,7 +33,7 @@ public class ClientTypeMiddleware(RequestDelegate next) context.Items["IsWebPage"] = isWebPage; - if (!isWebPage && !context.Request.Path.StartsWithSegments("/api")) + if (!isWebPage && context.Request.Path != "/ws" && !context.Request.Path.StartsWithSegments("/api")) context.Response.Redirect( $"/api{context.Request.Path.Value}{context.Request.QueryString.Value}", permanent: false diff --git a/DysonNetwork.Sphere/Connection/WebSocketController.cs b/DysonNetwork.Sphere/Connection/WebSocketController.cs index 484f12e..3bf61cf 100644 --- a/DysonNetwork.Sphere/Connection/WebSocketController.cs +++ b/DysonNetwork.Sphere/Connection/WebSocketController.cs @@ -8,10 +8,10 @@ using Swashbuckle.AspNetCore.Annotations; namespace DysonNetwork.Sphere.Connection; [ApiController] -[Route("/api/ws")] +[Route("/ws")] public class WebSocketController(WebSocketService ws, ILogger logger) : ControllerBase { - [Route("/api/ws")] + [Route("/ws")] [Authorize] [SwaggerIgnore] public async Task TheGateway()