问题:前端调试发现接口响应头中存在两个Access-Allow-Origin ,但是后端通过apifox或者postman调试都无法重新问题。
原因:后台在网关(spring cloud gateway)开启跨域后,在服务中也拦截了特定路径进行跨域。wtf。
spring:
cloud:
gateway:
#解决双重跨域
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials,
globalcors:
cors-configurations:
'[/**]':
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "x-requested-with,Content-Language,Authorization,Access-Control-Allow-Origin,request-id,Accept-Language,content-type,content-disposition"
allow-credentials: true