这是Webflux配置器的另一种解决方案。
旁注:它的Kotlin代码(从我的项目中复制),但是您可以轻松地将其转换为Java代码。
@Configuration@EnableWebFluxclass WebConfig: WebFluxConfigurer{ override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") .allowedOrigins("*") // any host or put domain(s) here .allowedMethods("GET, POST") // put the http verbs you want allow .allowedHeaders("Authorization") // put the http headers you want allow }}


