refactor: CORS origin 경로 설정 추가

This commit is contained in:
이상진 2025-08-03 20:48:34 +09:00
parent cfd35b875b
commit 15b9ef4a08
3 changed files with 11 additions and 2 deletions

View File

@ -1,14 +1,19 @@
package roomescape.common.config package roomescape.common.config
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration @Configuration
class CorsConfig : WebMvcConfigurer { class CorsConfig : WebMvcConfigurer {
@Value("\${cors-origin}")
private lateinit var origin: String
override fun addCorsMappings(registry: CorsRegistry) { override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**") registry.addMapping("/**")
.allowedOrigins("http://localhost:5173") .allowedOrigins(origin)
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
.allowedHeaders("Authorization", "Content-Type") .allowedHeaders("Authorization", "Content-Type")
.maxAge(3600) // 1 hour .maxAge(3600) // 1 hour

View File

@ -37,3 +37,5 @@ management:
tracing: tracing:
transport: ${OTLP_TRACING_PROTOCOL} transport: ${OTLP_TRACING_PROTOCOL}
endpoint: ${OTLP_TRACING_ENDPOINT} endpoint: ${OTLP_TRACING_ENDPOINT}
cors-origin: ${CORS_ORIGIN}

View File

@ -44,4 +44,6 @@ jdbc:
management: management:
tracing: tracing:
sampling: sampling:
probability: 1 probability: 1
cors-origin: "http://localhost:5173"