From 15b9ef4a08895628c77ca9bade3ed643d0c3d512 Mon Sep 17 00:00:00 2001 From: pricelees Date: Sun, 3 Aug 2025 20:48:34 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20CORS=20origin=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/roomescape/common/config/CorsConfig.kt | 7 ++++++- src/main/resources/application-deploy.yaml | 2 ++ src/main/resources/application-local.yaml | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/roomescape/common/config/CorsConfig.kt b/src/main/kotlin/roomescape/common/config/CorsConfig.kt index f66ed3fc..dfc8c9cd 100644 --- a/src/main/kotlin/roomescape/common/config/CorsConfig.kt +++ b/src/main/kotlin/roomescape/common/config/CorsConfig.kt @@ -1,14 +1,19 @@ package roomescape.common.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 class CorsConfig : WebMvcConfigurer { + + @Value("\${cors-origin}") + private lateinit var origin: String + override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") - .allowedOrigins("http://localhost:5173") + .allowedOrigins(origin) .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") .allowedHeaders("Authorization", "Content-Type") .maxAge(3600) // 1 hour diff --git a/src/main/resources/application-deploy.yaml b/src/main/resources/application-deploy.yaml index 6fc8619b..27e92be5 100644 --- a/src/main/resources/application-deploy.yaml +++ b/src/main/resources/application-deploy.yaml @@ -37,3 +37,5 @@ management: tracing: transport: ${OTLP_TRACING_PROTOCOL} endpoint: ${OTLP_TRACING_ENDPOINT} + +cors-origin: ${CORS_ORIGIN} \ No newline at end of file diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index 9d0c5b24..b69b1952 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -44,4 +44,6 @@ jdbc: management: tracing: sampling: - probability: 1 \ No newline at end of file + probability: 1 + +cors-origin: "http://localhost:5173" \ No newline at end of file