解决方案:【在网关中添加默认过滤器的配置】
spring:
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods: "*"
default-filters:
- DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
也可以进行用配置类Spring Cloud Gateway CORS 方案看这篇就够了-腾讯云开发者社区-腾讯云 (tencent.com)
或者
SpringCloud-Gateway解决跨域问题-腾讯云开发者社区-腾讯云 (tencent.com)
二者均可以使用