Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import org.springframework.security.config.annotation.web.invoke
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.CorsConfigurationSource
import org.springframework.web.cors.UrlBasedCorsConfigurationSource

@Configuration
class SecurityConfig(
Expand All @@ -27,6 +30,7 @@ class SecurityConfig(

http {
csrf { disable() }
cors { }
formLogin { disable() }
httpBasic { disable() }
logout { disable() }
Expand Down Expand Up @@ -78,4 +82,25 @@ class SecurityConfig(

return http.build()
}

@Bean
fun corsConfigurationSource(): CorsConfigurationSource {
return UrlBasedCorsConfigurationSource().apply {
registerCorsConfiguration(
"/**",
CorsConfiguration().apply {
allowedOriginPatterns =
listOf(
"http://localhost:3000",
"http://localhost:63342",
// 배포주소
)
allowedMethods = listOf("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
allowedHeaders = listOf("*")
allowCredentials = true
maxAge = 3600
},
)
}
}
}