setAllowedOrigins(“ *”)在服务器上不起作用。 CORS配置

问题描述 投票:-3回答:1

[我刚完成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();
}

你能帮我吗?我不知道我在做什么错

我刚刚完成了本教程,它可以在localhost上运行(当我在localhost:8080上运行后端,而在localhost:4200上运行时),但是当我将* .war文件放在服务器上时,出现了一些CORS问题。 ...

java angular websocket wildfly stomp
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.