Closed akiselevych closed 5 months ago
Hello!
As far as i can tell based on the snippets you provided this setup should work, and I am personally using an nearly identical setup in multiple apps myself. In fact the Example Project connects to a (Cross Origin) Backend which is implemented in Spring this way, you can find its source code here.
Please first check which headers are returned by spring in the failing request, and secondly please also check if the request path is routed to the Spring stomp Service correctly by opening the URL with your browser. The Response should look like this.
Thank you !
Hello. I have a problem with CORS. I configured my spring boot app and allow
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.setAllowedOriginPatterns("*")
.withSockJS();
}
But still receive CORS ErrorThis is how it looks in react
const HomePage = () => {
return (
<StompSessionProvider url={"http://localhost:9000/ws"}>
<TestComp/>
</StompSessionProvider>
)
}
const TestComp = () => {
useSubscription("/2/queue/messages", (message) => console.log(message));
return (
<p></p>
)
}
I also tried to allow strictly one origin, but it didnt help too (