Estoy usando spring boot en mi backend y vuejs en mi front-end. He definido todo en la guía pero todavía no logro que mi proyecto funcione.
Interfaz
connectToWS() { this.socket = new Sock("http://localhost:8754/stomp-endpoint"); this.stompClient = Stomp.over(this.socket); this.stompClient.connect( {}, frame => { this.connected = true; console.log(frame); this.stompClient.subscribe("/topic/greetings", tick => { console.log(tick); this.received_messages.push(JSON.parse(tick.body).content); }); }, error => { console.log(error); this.connected = false; } ); },back-end
Clase de configuración de WebSocket:
@Configuration @EnableWebSocketMessageBroker public class WebsocketConfiguration implements WebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { // with sockjs registry.addEndpoint("/stomp-endpoint") .setAllowedOrigins("http://localhost:8081") .withSockJS(); } @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.setApplicationDestinationPrefixes("/app") .enableSimpleBroker("/topic"); } }WebSecurityConfigClass:
@Override protected void configure(HttpSecurity http) throws Exception { http.cors().and().csrf().disable() .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .authorizeRequests() .antMatchers("/api/v*/registration/**").permitAll() .antMatchers("/topic**").permitAll() .antMatchers("/stomp-endpoint").permitAll()ACTUALIZACIÓN: El error en realidad proviene del navegador. En realidad, cambia la ruta de la API porque tiene sockjs integrado. No pude entender por qué la API siempre obtiene un /info?t=RandomNumber después. Necesito que la ruta siga siendo la misma que escribí en el front-end. ¿Cómo puedo evitar que el navegador actualice mi ruta? Gracias por ayudar !