From 0b65bcf8606839d4ef084f5d4505827f07c8c623 Mon Sep 17 00:00:00 2001 From: sumedh Date: Mon, 30 Sep 2024 19:17:01 +0530 Subject: [PATCH] cors changes applied & new-gw --- .gitignore | 2 +- .../apollo/config/WebSocketConfig.java | 6 ++- .../apollo/security/config/CorsConfig.java | 9 +++- src/main/resources/application.properties | 35 ------------- src/main/resources/application.yml | 49 +++++++++++++++++++ 5 files changed, 62 insertions(+), 39 deletions(-) delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml diff --git a/.gitignore b/.gitignore index a8d4013..592c513 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,5 @@ build/ ##changes in filepath before deploy #src/main/java/com/olympus/apollo/services/StorageProperties.java -#src/main/resources/application.properties +#src/main/resources/application.yml diff --git a/src/main/java/com/olympus/apollo/config/WebSocketConfig.java b/src/main/java/com/olympus/apollo/config/WebSocketConfig.java index 3672c72..a8225dd 100644 --- a/src/main/java/com/olympus/apollo/config/WebSocketConfig.java +++ b/src/main/java/com/olympus/apollo/config/WebSocketConfig.java @@ -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(); } diff --git a/src/main/java/com/olympus/apollo/security/config/CorsConfig.java b/src/main/java/com/olympus/apollo/security/config/CorsConfig.java index 7c6e6bb..f4f1dc7 100644 --- a/src/main/java/com/olympus/apollo/security/config/CorsConfig.java +++ b/src/main/java/com/olympus/apollo/security/config/CorsConfig.java @@ -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"); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index c426c9a..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,35 +0,0 @@ -spring.application.name=apollo -server.port=8082 -#spring.jpa.show-sql=true -#spring.jpa.hibernate.ddl-auto=update -#spring.datasource.url=jdbc:postgresql://localhost:5432/olympus -#spring.datasource.username=andreaterzani -#spring.datasource.password=26111979 -#spring.datasource.driver-class-name=org.postgresql.Driver -#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect - - -spring.ai.vectorstore.mongodb.uri= - -spring.data.mongodb.uri= -spring.data.mongodb.database= -spring.data.mongodb.username= -spring.data.mongodb.password= - -spring.ai.vectorstore.mongodb.indexName=vector_index -spring.ai.vectorstore.mongodb.collection-name=vector_store -spring.ai.vectorstore.mongodb.initialize-schema=false - -# API key if needed, e.g. OpenAI -spring.ai.openai.api-key= - -#size filter -spring.servlet.multipart.max-file-size=5000000MB -spring.servlet.multipart.max-request-size=500000MB - -#path to the repository -ingestion.repository.basepath=C:\\Users\\andrea.terzani\\dev\\Olympus - -gitlab.token= -#gitlab.path=C:\\repos\\olympus_ai\\gitClone -gitlab.path=/mnt/apollo_storage/repository \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..d625139 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,49 @@ +server: + port: 8082 + +apollo: + fe: + url: "http://localhost:5173" +spring: + application: + name: apollo + ai: + openai: + api-key: + vectorstore: + mongodb: + uri: + indexName: vector_index + collection-name: vector_store + initialize-schema: false + data: + mongodb: + uri: + database: + username: + password: + servlet: + multipart: + max-file-size: 5000000MB + max-request-size: 500000MB + +#path to the repository +ingestion: + repository: + basepath: C:\\Users\\andrea.terzani\\dev\\Olympus +gitlab: + token: + path: /mnt/apollo_storage/repository #C:\\repos\\olympus_ai\\gitClone + + +#spring.jpa.show-sql=true +#spring.jpa.hibernate.ddl-auto=update +#spring.datasource.url=jdbc:postgresql://localhost:5432/olympus +#spring.datasource.username=andreaterzani +#spring.datasource.password=26111979 +#spring.datasource.driver-class-name=org.postgresql.Driver +#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect + +logging: + level: + root: INFO \ No newline at end of file