cors changes applied & new-gw

This commit is contained in:
sumedh
2024-09-30 19:17:01 +05:30
parent 172573d2c5
commit 0b65bcf860
5 changed files with 62 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
package com.olympus.apollo.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
@@ -10,10 +11,13 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Value("${apollo.fe.url}")
private String apollo_frontend_url;
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws/endpoint")
.setAllowedOrigins("http://olympus-api-gateway.olympusai.live")
.setAllowedOrigins(apollo_frontend_url)
.withSockJS();
}

View File

@@ -1,17 +1,22 @@
package com.olympus.apollo.security.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Value("${apollo.fe.url}")
private String apollo_frontend_url;
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedOrigins(apollo_frontend_url)
.allowedHeaders("*")
.allowedMethods("GET", "POST", "PUT", "DELETE");
.allowedMethods("GET", "POST", "PUT", "DELETE","OPTIONS");
}
}