0.10.2 修复跨域问题
This commit is contained in:
@@ -21,7 +21,7 @@ allprojects {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
ext {
|
ext {
|
||||||
version '0.10.1'
|
version '0.10.2'
|
||||||
spring_version = "2.3.0.RELEASE"
|
spring_version = "2.3.0.RELEASE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Component
|
|||||||
import org.springframework.web.cors.CorsConfiguration
|
import org.springframework.web.cors.CorsConfiguration
|
||||||
import org.springframework.web.cors.CorsConfigurationSource
|
import org.springframework.web.cors.CorsConfigurationSource
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -56,9 +57,15 @@ class WebSecurity : WebSecurityConfigurerAdapter() {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
fun corsConfigurationSource(): CorsConfigurationSource {
|
fun corsConfigurationSource(): CorsConfigurationSource {
|
||||||
|
val configuration = CorsConfiguration()
|
||||||
|
configuration.allowedOrigins = listOf("*")
|
||||||
|
configuration.allowedMethods = listOf("*")
|
||||||
|
configuration.allowedHeaders = listOf("*")
|
||||||
|
// 如果所有的属性不全部配置,一定要执行该方法
|
||||||
|
configuration.applyPermitDefaultValues()
|
||||||
val source = UrlBasedCorsConfigurationSource()
|
val source = UrlBasedCorsConfigurationSource()
|
||||||
// 注册跨域配置
|
// 注册跨域配置
|
||||||
source.registerCorsConfiguration("/**", CorsConfiguration().applyPermitDefaultValues())
|
source.registerCorsConfiguration("/**", configuration)
|
||||||
return source
|
return source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user