版本信息:
spring-boot.version:3.0.2
spring-cloud-starter-gateway.version4.0.0
代码配置:
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;
/**
* 跨域配置
*/
@Configuration
public class GlobalCorsConfig implements WebFluxConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedHeaders("*")
.maxAge(3600L);
}
}
不足之处请谅解,一起讨论学习,共同进步!