【问题标题】:setAllowedOrigins("*") don't works on server. CORS configurationsetAllowedOrigins("*") 在服务器上不起作用。 CORS 配置
【发布时间】: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


【解决方案1】:

问题是野蝇。我只是在没有wildfly的服务器上运行jar,并且websocket正常工作。我可能没有在 Wildfly 中配置一些东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 2020-06-23
    • 2012-09-03
    • 2019-09-25
    相关资源
    最近更新 更多