且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebSockets请求中的请求资源上不存在“ Access-Control-Allow-Origin”标头

更新时间:2022-02-12 03:35:14

如果有人会有这个问题,我可以这样在WebsocketConfig中解决我的问题:

If someone will have this question, I solved my problem in WebsocketConfig like this:

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat").setAllowedOrigins("http://localhost:3000").withSockJS();
}