knightlock_
knightlock_
RRailway
Created by knightlock_ on 7/24/2024 in #✋|help
Connecting a Websocket over a Caddy Proxy returns 405 Method Not Allowed with a POST call
hey folks, Im newer to websocket integration so bear with me. I have a spring boot project connecting to a websocket using sockjs-client from my react front end and connecting to a STOMP entrypoint on the spring boot backend. Locally, this works great. However, I am getting a 405 method not allowed when connecting to out railway project. We are using Caddy Proxy to create a proxied URL so this may have something to do with it although Im not sure.
my react call is: let sock = new SockJS('ws'); stompClient = over(sock); stompClient.connect({} ,onConnected, onError); which I get the error: Request URL: https://XXXXXXX.XXXXXXX.com/ws/021/bntqbx12/xhr_streaming?t=1721787651124 Request Method: POST Status Code: 405 Method Not Allowed Remote Address: 34.86.119.124:443 Referrer Policy: strict-origin-when-cross-origin this is because railway only allows for GET and HEAD requests.
Allow: GET, HEAD Content-Length: 0 Date: Wed, 24 Jul 2024 02:20:51 GMT Server: railway on the back end: @Configuration @EnableWebSocketMessageBroker @EnableWebSocket public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) { stompEndpointRegistry.addEndpoint("/ws") .setAllowedOriginPatterns("*") .withSockJS(); } we also have a package json proxy as well for our api requests if that is also important: "proxy": "http://locahost:8081" I can provide more info if you need it. Thanks in advance!
35 replies