Skip to content

Commit 70f2575

Browse files
fix(infrastructure): fix websockets cors
1 parent be3ec9e commit 70f2575

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Changed
1212
- Make login QR padding white.
13+
### Fixed
14+
- Add WebSockets CORS.
1315

1416
## [v2.0.0](https://github.com/in2workspace/in2-verifier-api/releases/tag/v2.0.0)
1517
- New major version to align with the new major version of EUDIStack project.

src/main/java/es/in2/vcverifier/config/WebSocketConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
package es.in2.vcverifier.config;
22

3+
import lombok.RequiredArgsConstructor;
34
import org.springframework.context.annotation.Configuration;
45
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
56
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
67
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
78
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
89

910
@Configuration
11+
@RequiredArgsConstructor
1012
@EnableWebSocketMessageBroker
1113
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
1214

15+
private final BackendConfig backendConfig;
16+
1317
@Override
1418
public void configureMessageBroker(MessageBrokerRegistry config) {
1519
// Habilitar el broker solo para el canal /oidc
@@ -19,7 +23,9 @@ public void configureMessageBroker(MessageBrokerRegistry config) {
1923
@Override
2024
public void registerStompEndpoints(StompEndpointRegistry registry) {
2125
// Registrar el endpoint de WebSocket para que los clientes se conecten
22-
registry.addEndpoint("/qr-socket").withSockJS();
26+
registry.addEndpoint("/qr-socket")
27+
.setAllowedOrigins(backendConfig.getUrl())
28+
.withSockJS();
2329
}
2430

2531
}

0 commit comments

Comments
 (0)