【发布时间】:2020-09-25 16:31:19
【问题描述】:
我刚刚完成this tutorial,它可以在 localhost 上运行(当我在 localhost:8080 上运行后端并在 localhost:4200 上运行前端时),但是当我将 *.war 文件放在服务器上时,出现了一些 CORS 问题。
跨域请求被阻止:同源策略不允许读取位于“http://mydomain.pl/ws/info?t=1591451334475”的远程资源。 (原因:如果 CORS 标头“Access-Control-Allow-Origin”为“*”,则不支持凭据)
我将其更改为允许,但这不起作用:(
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.setAllowedOrigins("*")
.withSockJS();
}
你能帮帮我吗?我不知道我做错了什么
【问题讨论】:
-
否则试试
.setAllowedOrigins("http://localhost:4200")
标签: java angular websocket wildfly stomp