今天在使用Vue做前端页面发请求的时候遇到以下问题:
报错截图:
问题原因:
这是因为Vue的后端gateway做了一次跨域设置,而vue的前端又向其他的后台服务也发请求,如果其他的后端服务如果也做了跨域设置就会导致重复跨域问题。
解决办法:
spring:
cloud:
gateway:
#解决双重跨域
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_UNIQUE
globalcors:
cors-configurations:
'[/**]':
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true