forked from AdamRepasky/feedback-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a logger and inserted some diagnostics relating to communication with the UI. Also removed the hard-coded CORS, putting it into an environment variable.
- Loading branch information
Gerhard Salvini
committed
Nov 27, 2024
1 parent
44216b2
commit 9dd3557
Showing
8 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
FROM eclipse-temurin:17-jre | ||
ARG JAR_FILE=target/*.jar | ||
COPY ${JAR_FILE} application.jar | ||
ENTRYPOINT ["java", "-jar", "application.jar"] | ||
#ENTRYPOINT ["java", "-jar", "application.jar"] | ||
|
||
# Remote debugging with VS | ||
EXPOSE 5005 | ||
ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-jar", "application.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/com/samply/feedbackagent/FeedbackAgentApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/samply/feedbackagent/controller/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.samply.feedbackagent.controller; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
@Configuration | ||
public class CorsConfig { | ||
private static final Logger logger = LogManager.getLogger(CorsConfig.class); | ||
|
||
// Load the CORS origin dynamically, e.g., from environment variables or properties | ||
@Value("${fa.cors.origin}") | ||
String corsOrigin; | ||
|
||
@Bean | ||
public CorsFilter corsFilter() { | ||
logger.info("corsFilter: corsOrigin: " + corsOrigin); | ||
CorsConfiguration config = new CorsConfiguration(); | ||
config.addAllowedOrigin(corsOrigin); // Set your dynamic origin | ||
config.addAllowedHeader("*"); // Allow all headers | ||
config.addAllowedMethod("*"); // Allow all HTTP methods | ||
config.setAllowCredentials(true); // Allow cookies if necessary | ||
|
||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
source.registerCorsConfiguration("/**", config); | ||
|
||
return new CorsFilter(source); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/samply/feedbackagent/service/Configuration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.samply.feedbackagent.service; | ||
|
||
import lombok.Data; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** Environment configuration parameters. */ | ||
@Data | ||
@Component | ||
public class Configuration { | ||
@Value("${fa.cors.origin}") | ||
private String corsOrigin; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters