前端--> nginx-->gateway产生的跨域问题分析

1、后台服务是否配置cors,或者添加CorsFilter。

2、确认前端求header参数被包含在cors配置中。

3、检查CorsFilter的顺序是否是filterChain第一位,如果不是,看他前面的filter是否可以通过。

4、如果无法通过,检查nginx.conf文件中是否配置

复制代码
#  给response header 添加如下参数

add_header 'Access-Control-Allow-Origin' '*' ;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' ;
add_header 'Access-Control-Allow-Headers' 'Content-Type,x-format,x-language,x-locale,x-requested-with' ;
add_header 'Access-Control-Allow-Credentials' 'true' ;
                        #     if ($request_method = 'OPTIONS') {
                        #         add_header 'Access-Control-Allow-Origin' '*';
                        #         add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                        #         add_header 'Access-Control-Allow-Headers' 'Content-Type,x-format,x-language,x-locale,x-requested-with' always;
                        #         add_header 'Access-Control-Allow-Credentials' 'true';
                        #         return 204;
                        #         }
相关推荐
不知几秋几秒前
Spring Boot
java·前端·spring boot
程序猿ZhangSir4 分钟前
Vue3 项目的基本架构解读
前端·javascript·vue.js
HarderCoder9 分钟前
ByAI: Redux的typescript简化实现
前端
90后的晨仔16 分钟前
RxSwift 框架解析
前端·ios
我命由我1234522 分钟前
VSCode - VSCode 放大与缩小代码
前端·ide·windows·vscode·前端框架·编辑器·软件工具
Mintopia30 分钟前
当数字橡皮泥遇上魔法:探秘计算机图形学的细分曲面
前端·javascript·计算机图形学
欧先生^_^36 分钟前
ingress-nginx 开启 Prometheus 监控 + Grafana 查看指标
nginx·grafana·prometheus
Mintopia38 分钟前
Three.js 物理引擎:给你的 3D 世界装上 “牛顿之魂”
前端·javascript·three.js
Jeremy_Lee12341 分钟前
grafana 批量视图备份及恢复(含数据源)
前端·网络·grafana
import_random1 小时前
[python]conda
前端