前端--> 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;
                        #         }
相关推荐
编程社区管理员4 小时前
React 发送短信验证码和验证码校验功能组件
前端·javascript·react.js
全马必破三4 小时前
React“组件即函数”
前端·javascript·react.js
三思而后行,慎承诺4 小时前
React 底层原理
前端·react.js·前端框架
座山雕~4 小时前
html 和css基础常用的标签和样式
前端·css·html
灰小猿5 小时前
Spring前后端分离项目时间格式转换问题全局配置解决
java·前端·后端·spring·spring cloud
im_AMBER5 小时前
React 16
前端·笔记·学习·react.js·前端框架
02苏_5 小时前
ES6模板字符串
前端·ecmascript·es6
excel5 小时前
⚙️ 一次性警告机制的实现:warnOnce 源码深度解析
前端
excel5 小时前
Vue SFC 样式编译核心机制详解:compileStyle 与 PostCSS 管线设计
前端
excel5 小时前
🧩 使用 Babel + MagicString 实现动态重写 export default 的通用方案
前端