前后端分離項目中前端出現了跨域的問題?
在網關模塊配置文件中添加 配置
application.properties
# 允許請求來源(老版本叫allowedOrigin)
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowedOriginPatterns=*
# 允許攜帶的頭信息
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowedHeaders=*
# 允許的請求方式
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowedMethods=*
# 是否允許攜帶cookie
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowCredentials=true
# 跨域檢測的有效期,會發起一個OPTION請求
spring.cloud.gateway.globalcors.cors-configurations.[/**].maxAge=3600
?