Skip to content

Commit

Permalink
chore: cors 코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
whereami2048 committed Jan 5, 2025
1 parent 55fc83f commit 56a27af
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,7 @@ class SecurityConfig {
jwtAuthenticationFilter: JwtAuthenticationFilter,
apiExceptionHandlingFilter: ApiExceptionHandlingFilter,
): SecurityFilterChain {
val configuration = CorsConfiguration()
val source = UrlBasedCorsConfigurationSource()

configuration.allowedOrigins = listOf(
"http://localhost:3000",
"http://localhost:80",
"https://vacgom.co.kr"
)
configuration.allowedMethods = listOf(
"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"
)
configuration.allowedHeaders = listOf("*")

source.registerCorsConfiguration("/yaho", configuration)

httpSecurity {
cors { configurationSource = source }
authorizeHttpRequests { authorize(anyRequest, permitAll) }
httpBasic { disable() }
formLogin { disable() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BabyController(
babyCommandService.createBaby(userId, request)
}

@PostMapping("/images", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE], produces = [MediaType.APPLICATION_JSON_VALUE])
@PostMapping("/images", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE], produces = [MediaType.APPLICATION_JSON_VALUE])
override fun uploadBabyImage(@ModelAttribute request: BabyDto.Request.UploadImage): BaseResponse<List<BabyDto.Response.UploadedImage>> {
return babyImageService.uploadBabyImages(request.images).let { BaseResponse.success(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
class CorsConfig : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("https://api-dev-v2.vacgom.co.kr", "http://localhost:80", "http://localhost:3000", "https://vacgom.co.kr")
.allowedOrigins("https://api-dev-v2.vacgom.co.kr", "http://localhost:3000", "https://vacgom.co.kr")
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
.allowedHeaders("*")
}
Expand Down

0 comments on commit 56a27af

Please sign in to comment.