Skip to content

Commit

Permalink
chore: add allowed origins param
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Eberl committed Jun 29, 2021
1 parent ce99dcf commit dfdd376
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand All @@ -18,10 +17,4 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
.addResourceLocations("classpath:/META-INF/resources/");
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
@RequiredArgsConstructor
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@Value("${app.base.url}")
private String appBaseUrl;
@Value("${allowed.origins}")
private String[] allowedOrigins;

private final @NonNull ClientInboundChannelInterceptor clientInboundChannelInterceptor;

Expand All @@ -46,7 +46,7 @@ public void configureMessageBroker(MessageBrokerRegistry config) {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/live")
.setAllowedOrigins(this.appBaseUrl)
.setAllowedOrigins(this.allowedOrigins)
.withSockJS();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ keycloak.resource=
keycloak.disable-trust-manager=true

app.base.url=
allowed.origins=

# Springfox/API documentation
springfox.docuTitle=Caritas Online Beratung: LiveService
Expand Down

0 comments on commit dfdd376

Please sign in to comment.