fix: 修复nginx /ws拦截问题

This commit is contained in:
Tim
2025-08-22 15:26:41 +08:00
parent 67e912381b
commit 0ed9ad2f2a
4 changed files with 78 additions and 75 deletions

View File

@@ -41,8 +41,7 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
// Registers the "/ws" endpoint, enabling SockJS fallback options so that alternate transports may be used if WebSocket is not available.
registry.addEndpoint("/ws")
registry.addEndpoint("/api/ws")
// 安全改进:使用具体的允许源,而不是通配符
.setAllowedOrigins(
"http://127.0.0.1:8080",