Skip to content

Commit

Permalink
remove cors config
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kerkhoff committed Nov 18, 2024
1 parent 2c3440a commit 3be20a1
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SecurityConfig {
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http {
csrf { disable() }
cors { }
// cors { }
authorizeRequests {
authorize(anyRequest, authenticated)
}
Expand All @@ -37,22 +37,22 @@ class SecurityConfig {
return http.build()
}

@Bean
fun corsFilter(): CorsFilter {
val source = UrlBasedCorsConfigurationSource()
val config = CorsConfiguration()
config.allowCredentials = true
config.allowedOrigins = listOf(
"http://localhost:5173",
"http://localhost:5174",
)
config.allowedHeaders = listOf(
"Origin", "Content-Type", "Accept", "Authorization",
"Access-Control-Allow-Origin"
)
config.allowedMethods =
listOf("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
source.registerCorsConfiguration("/**", config)
return CorsFilter(source)
}
// @Bean
// fun corsFilter(): CorsFilter {
// val source = UrlBasedCorsConfigurationSource()
// val config = CorsConfiguration()
// config.allowCredentials = true
// config.allowedOrigins = listOf(
// "http://localhost:5173",
// "http://localhost:5174",
// )
// config.allowedHeaders = listOf(
// "Origin", "Content-Type", "Accept", "Authorization",
// "Access-Control-Allow-Origin"
// )
// config.allowedMethods =
// listOf("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
// source.registerCorsConfiguration("/**", config)
// return CorsFilter(source)
// }
}

0 comments on commit 3be20a1

Please sign in to comment.