Spring Boot接口如何配置跨域访问

1
2
3
4
5
6
@Bean
fun webMvcConfigurer() = object : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/api/**").allowedOrigins("http://localhost:3000", "https://blog.pisikeji.com")
}
}
分享到