【发布时间】:2020-05-02 05:15:58
【问题描述】:
我正在使用 websockets 在服务器和客户端之间进行通信。我按照这个文档来实现 websocket 依赖。现在,当我尝试通过示例客户端页面连接时,会产生以下错误:
Access to XMLHttpRequest at '....' from origin 'null' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
我尝试将.setAllowedOrigins("*") 添加到WebSocketConfig,但没有解决这个问题。解决办法是什么?
【问题讨论】:
-
您的客户使用 SockJs 吗?
-
您能否详细说明您的客户端应用程序和配置?
-
@MehrdadHosseinNejad 是的,它正在使用 sockJs
标签: spring spring-websocket java-websocket