From 37900bc697a5d00d0e4e529ac79d4e3838e86b1f Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 00:53:49 +0900 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20=EC=97=AC=EB=9F=AC=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=EC=9D=84=20CORS=20=ED=97=88=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20CorsConfig=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ddangkong/config/CorsConfig.java | 10 +++++----- .../java/ddangkong/config/CorsProperties.java | 20 +++++++++++++++++++ .../src/main/resources/application-dev.yml | 4 +++- .../src/main/resources/application-prod.yml | 4 +++- 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 backend/src/main/java/ddangkong/config/CorsProperties.java diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index 0065883ab..6a098f87e 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -1,6 +1,5 @@ package ddangkong.config; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.web.servlet.config.annotation.CorsRegistry; @@ -9,16 +8,17 @@ @Configuration public class CorsConfig implements WebMvcConfigurer { - private final String[] corsOrigin; + private final CorsProperties corsProperties; - public CorsConfig(@Value("${cors.origin}") String[] corsOrigin) { - this.corsOrigin = corsOrigin; + public CorsConfig(CorsProperties corsProperties) { + System.out.println(corsProperties.getOrigin()); + this.corsProperties = corsProperties; } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOriginPatterns(corsOrigin) + .allowedOriginPatterns(corsProperties.getOrigins()) .allowedMethods( HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name() ) diff --git a/backend/src/main/java/ddangkong/config/CorsProperties.java b/backend/src/main/java/ddangkong/config/CorsProperties.java new file mode 100644 index 000000000..2389bac08 --- /dev/null +++ b/backend/src/main/java/ddangkong/config/CorsProperties.java @@ -0,0 +1,20 @@ +package ddangkong.config; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Getter +@Setter +@Component +@ConfigurationProperties(prefix = "cors") +public class CorsProperties { + + private List origin; + + public String[] getOrigins() { + return origin.toArray(String[]::new); + } +} diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml index e7853e0f6..68ad8c20a 100644 --- a/backend/src/main/resources/application-dev.yml +++ b/backend/src/main/resources/application-dev.yml @@ -19,7 +19,9 @@ spring: default_batch_fetch_size: 1000 cors: - origin: ${secret.cors.origin} + origin: + - ${secret.cors.origin1} + - ${secret.cors.origin2} cookie: rejoin-key: ${secret.cookie.rejoin-key} diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index d7369aa59..62fbfc198 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -21,7 +21,9 @@ spring: batch_size: 1000 cors: - origin: ${secret.cors.origin} + origin: + - ${secret.cors.origin1} + - ${secret.cors.origin2} cookie: rejoin-key: ${secret.cookie.rejoin-key} From 17a178b2a8ce0336f839a1b481e29e29855210db Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 00:54:29 +0900 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20=EC=9E=98=EB=AA=BB=20=ED=91=9C?= =?UTF-8?q?=EA=B8=B0=EB=90=9C=20=EC=97=90=EB=9F=AC=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=88=98=EC=A0=95=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/exception/ClientErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/exception/ClientErrorCode.java b/backend/src/main/java/ddangkong/exception/ClientErrorCode.java index 54bc19e56..96a0a83a5 100644 --- a/backend/src/main/java/ddangkong/exception/ClientErrorCode.java +++ b/backend/src/main/java/ddangkong/exception/ClientErrorCode.java @@ -59,7 +59,7 @@ public enum ClientErrorCode { BLANK_BALANCE_CONTENT_NAME("컨텐츠 이름이 비어 있습니다."), LONG_BALANCE_CONTENT_NAME("컨텐츠 이름은 최대 %d자 입니다."), BLANK_BALANCE_OPTION_NAME("컨텐츠 옵션이 비어 있습니다."), - LONG_BALANCE_OPTION_NAME("컨텐츠 옵션은 최대 %자 입니다."), + LONG_BALANCE_OPTION_NAME("컨텐츠 옵션은 최대 %d자 입니다."), ALREADY_USING_AT_ROOM_BALANCE_CONTENT("현재 게임에서 사용 중인 컨텐츠입니다."), // Common From e67c0740ff86c28a3a089c29a22757a6cfce2b1e Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 01:07:42 +0900 Subject: [PATCH 03/11] =?UTF-8?q?test:=20test=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EC=97=90=EC=84=9C=20CorsConfig=20=EA=B0=80=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=EC=9E=91=EB=8F=99=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../documentation/BaseDocumentationTest.java | 3 + backend/src/test/resources/application.yml | 56 ++++++++++--------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java b/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java index 903f7c13a..38d9676ba 100644 --- a/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java +++ b/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java @@ -7,9 +7,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import com.fasterxml.jackson.databind.ObjectMapper; +import ddangkong.config.CorsProperties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.http.HttpHeaders; import org.springframework.restdocs.RestDocumentationContextProvider; import org.springframework.restdocs.RestDocumentationExtension; @@ -18,6 +20,7 @@ import org.springframework.web.context.WebApplicationContext; @ExtendWith(RestDocumentationExtension.class) +@EnableConfigurationProperties(CorsProperties.class) public abstract class BaseDocumentationTest { @Autowired diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml index a14bc8cee..ed7e50d89 100644 --- a/backend/src/test/resources/application.yml +++ b/backend/src/test/resources/application.yml @@ -1,7 +1,22 @@ spring: profiles: active: test + +--- + +spring: + config: + activate: + on-profile: test + + datasource: + driver-class-name: org.h2.Driver + url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 + username: sa + jpa: + hibernate: + ddl-auto: create properties: hibernate: format_sql: true @@ -10,20 +25,6 @@ spring: database-platform: org.hibernate.dialect.H2Dialect defer-datasource-initialization: true -cors: - origin: "*" - -cookie: - rejoin-key: test_cookie - -encrypt: - secret-key: 1234567890123456 - algorithm: AES - -admin: - session-key : admin - password : 1234 - logging: level: org: @@ -35,15 +36,18 @@ logging: transaction: interceptor: TRACE ---- -spring: - config: - activate: - on-profile: test - datasource: - driver-class-name: org.h2.Driver - url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 - username: sa - jpa: - hibernate: - ddl-auto: create +cors: + origin: + - "*" + +cookie: + rejoin-key: test_cookie + +encrypt: + secret-key: 1234567890123456 + algorithm: AES + +admin: + session-key: admin + password: 1234 + From 4db28cd02e17511fd0da2b9d91f11a2dc16df072 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 01:08:07 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20CorsProperties=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=88=9C=EC=84=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/config/CorsProperties.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/ddangkong/config/CorsProperties.java b/backend/src/main/java/ddangkong/config/CorsProperties.java index 2389bac08..f57bafadb 100644 --- a/backend/src/main/java/ddangkong/config/CorsProperties.java +++ b/backend/src/main/java/ddangkong/config/CorsProperties.java @@ -6,10 +6,10 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +@ConfigurationProperties(prefix = "cors") +@Component @Getter @Setter -@Component -@ConfigurationProperties(prefix = "cors") public class CorsProperties { private List origin; From 91b6a089341fc4059a9c919b26b31b67b1b29aba Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 01:41:13 +0900 Subject: [PATCH 05/11] =?UTF-8?q?feat:=20=EB=94=94=EB=B2=84=EA=B9=85?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EB=A1=9C=EA=B9=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/config/CorsConfig.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index 6a098f87e..d34f9e332 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -1,17 +1,19 @@ package ddangkong.config; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +@Slf4j @Configuration public class CorsConfig implements WebMvcConfigurer { private final CorsProperties corsProperties; public CorsConfig(CorsProperties corsProperties) { - System.out.println(corsProperties.getOrigin()); + log.info("CORS 허용 확인 : {}", corsProperties.getOrigin()); // TODO 제거하기 this.corsProperties = corsProperties; } From 42af7fa8ae3befedc7d504a301a4b8d6ea9c3c27 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 01:56:33 +0900 Subject: [PATCH 06/11] =?UTF-8?q?fix:=20allowedOrigins=20=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/config/CorsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index d34f9e332..5c53d40bc 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -20,7 +20,7 @@ public CorsConfig(CorsProperties corsProperties) { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOriginPatterns(corsProperties.getOrigins()) + .allowedOrigins(corsProperties.getOrigins()) .allowedMethods( HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name() ) From b828c52252949e59618a433c5ca7eca0b1ce7003 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 02:00:21 +0900 Subject: [PATCH 07/11] =?UTF-8?q?fix:=20allowedOriginPatterns=20=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/config/CorsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index 5c53d40bc..d34f9e332 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -20,7 +20,7 @@ public CorsConfig(CorsProperties corsProperties) { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOrigins(corsProperties.getOrigins()) + .allowedOriginPatterns(corsProperties.getOrigins()) .allowedMethods( HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name() ) From 036c0b7f82f7c5602ec18172d8f47025f80cbd3e Mon Sep 17 00:00:00 2001 From: leegwichan Date: Mon, 6 Jan 2025 10:13:06 +0900 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20CORS=20OPTIONS=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=ED=97=88=EC=9A=A9=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/ddangkong/config/CorsConfig.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index d34f9e332..a95a100c9 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -22,7 +22,11 @@ public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOriginPatterns(corsProperties.getOrigins()) .allowedMethods( - HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name() + HttpMethod.GET.name(), + HttpMethod.POST.name(), + HttpMethod.PATCH.name(), + HttpMethod.DELETE.name(), + HttpMethod.OPTIONS.name() ) .allowCredentials(true) .allowedHeaders("*"); From 0df9d946186d7a7aa35a761e6a7f9057fbf1514b Mon Sep 17 00:00:00 2001 From: leegwichan Date: Wed, 8 Jan 2025 12:54:59 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 로깅을 위한 sudo 권한 추가 --- backend/scripts/dev/replace-new-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/scripts/dev/replace-new-version.sh b/backend/scripts/dev/replace-new-version.sh index c94ac3191..e86b27e8f 100644 --- a/backend/scripts/dev/replace-new-version.sh +++ b/backend/scripts/dev/replace-new-version.sh @@ -19,4 +19,4 @@ fi JAR_FILE=$(ls /home/ubuntu/app/*.jar | head -n 1) -nohup java -Dspring.profiles.active=dev -Duser.timezone=Asia/Seoul -Dserver.port=8080 -jar "$JAR_FILE" & +sudo nohup java -Dspring.profiles.active=dev -Duser.timezone=Asia/Seoul -Dserver.port=8080 -jar "$JAR_FILE" & From ca1714a12340c54ff15739ef15536a8aed84e3a0 Mon Sep 17 00:00:00 2001 From: leegwichan Date: Wed, 8 Jan 2025 13:30:16 +0900 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20Interceptor=20=EC=97=90=20Prefligh?= =?UTF-8?q?t=20=EC=9A=94=EC=B2=AD=EC=9D=80=20=ED=86=B5=EA=B3=BC=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/AdminAuthorizationInterceptor.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ddangkong/controller/admin/AdminAuthorizationInterceptor.java b/backend/src/main/java/ddangkong/controller/admin/AdminAuthorizationInterceptor.java index ec3d3ade5..7f045ab90 100644 --- a/backend/src/main/java/ddangkong/controller/admin/AdminAuthorizationInterceptor.java +++ b/backend/src/main/java/ddangkong/controller/admin/AdminAuthorizationInterceptor.java @@ -4,7 +4,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; @@ -20,13 +22,22 @@ public AdminAuthorizationInterceptor(@Value("${admin.session-key}") String sessi } @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + public boolean preHandle(@NotNull HttpServletRequest request, + @NotNull HttpServletResponse response, + @NotNull Object handler) { + if (isPreflightRequest(request)) { + return true; + } if (hasAdminAuthAnnotation(handler)) { authorizeAdmin(request); } return true; } + private boolean isPreflightRequest(HttpServletRequest request) { + return HttpMethod.OPTIONS.name().equals(request.getMethod()); + } + private boolean hasAdminAuthAnnotation(Object handler) { if (handler instanceof ResourceHttpRequestHandler) { return false; From 43b75d5e53aea2141c8581ff1560cb4d044e585c Mon Sep 17 00:00:00 2001 From: leegwichan Date: Wed, 8 Jan 2025 14:03:21 +0900 Subject: [PATCH 11/11] =?UTF-8?q?refactor:=20CorsConfig=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=A1=A4?= =?UTF-8?q?=EB=B0=B1=20#459?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ddangkong/config/CorsConfig.java | 12 +++++------ .../java/ddangkong/config/CorsProperties.java | 20 ------------------- .../src/main/resources/application-dev.yml | 4 +--- .../src/main/resources/application-prod.yml | 4 +--- .../documentation/BaseDocumentationTest.java | 3 --- backend/src/test/resources/application.yml | 3 +-- 6 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 backend/src/main/java/ddangkong/config/CorsProperties.java diff --git a/backend/src/main/java/ddangkong/config/CorsConfig.java b/backend/src/main/java/ddangkong/config/CorsConfig.java index a95a100c9..d26d7a711 100644 --- a/backend/src/main/java/ddangkong/config/CorsConfig.java +++ b/backend/src/main/java/ddangkong/config/CorsConfig.java @@ -1,26 +1,24 @@ package ddangkong.config; -import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -@Slf4j @Configuration public class CorsConfig implements WebMvcConfigurer { - private final CorsProperties corsProperties; + private final String[] corsOrigin; - public CorsConfig(CorsProperties corsProperties) { - log.info("CORS 허용 확인 : {}", corsProperties.getOrigin()); // TODO 제거하기 - this.corsProperties = corsProperties; + public CorsConfig(@Value("${cors.origin}") String[] corsOrigin) { + this.corsOrigin = corsOrigin; } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOriginPatterns(corsProperties.getOrigins()) + .allowedOriginPatterns(corsOrigin) .allowedMethods( HttpMethod.GET.name(), HttpMethod.POST.name(), diff --git a/backend/src/main/java/ddangkong/config/CorsProperties.java b/backend/src/main/java/ddangkong/config/CorsProperties.java deleted file mode 100644 index f57bafadb..000000000 --- a/backend/src/main/java/ddangkong/config/CorsProperties.java +++ /dev/null @@ -1,20 +0,0 @@ -package ddangkong.config; - -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@ConfigurationProperties(prefix = "cors") -@Component -@Getter -@Setter -public class CorsProperties { - - private List origin; - - public String[] getOrigins() { - return origin.toArray(String[]::new); - } -} diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml index 68ad8c20a..e7853e0f6 100644 --- a/backend/src/main/resources/application-dev.yml +++ b/backend/src/main/resources/application-dev.yml @@ -19,9 +19,7 @@ spring: default_batch_fetch_size: 1000 cors: - origin: - - ${secret.cors.origin1} - - ${secret.cors.origin2} + origin: ${secret.cors.origin} cookie: rejoin-key: ${secret.cookie.rejoin-key} diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index 62fbfc198..d7369aa59 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -21,9 +21,7 @@ spring: batch_size: 1000 cors: - origin: - - ${secret.cors.origin1} - - ${secret.cors.origin2} + origin: ${secret.cors.origin} cookie: rejoin-key: ${secret.cookie.rejoin-key} diff --git a/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java b/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java index 38d9676ba..903f7c13a 100644 --- a/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java +++ b/backend/src/test/java/ddangkong/documentation/BaseDocumentationTest.java @@ -7,11 +7,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import com.fasterxml.jackson.databind.ObjectMapper; -import ddangkong.config.CorsProperties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.http.HttpHeaders; import org.springframework.restdocs.RestDocumentationContextProvider; import org.springframework.restdocs.RestDocumentationExtension; @@ -20,7 +18,6 @@ import org.springframework.web.context.WebApplicationContext; @ExtendWith(RestDocumentationExtension.class) -@EnableConfigurationProperties(CorsProperties.class) public abstract class BaseDocumentationTest { @Autowired diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml index ed7e50d89..0a28c4546 100644 --- a/backend/src/test/resources/application.yml +++ b/backend/src/test/resources/application.yml @@ -37,8 +37,7 @@ logging: interceptor: TRACE cors: - origin: - - "*" + origin: '*' cookie: rejoin-key: test_cookie