前端--> 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;
                        #         }
相关推荐
KaMeidebaby7 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
nuIl8 小时前
实现一个 Coding Agent(3):工具调用
前端·agent·cursor
nuIl8 小时前
实现一个 Coding Agent(4):ReAct 循环
前端·agent·cursor
nuIl8 小时前
实现一个 Coding Agent(1):一次 LLM 调用
前端·agent·cursor
nuIl8 小时前
实现一个 Coding Agent(2):让 LLM 流式响应
前端·agent·cursor
copyer_xyf8 小时前
Python 异常处理
前端·后端·python
sugar__salt8 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
独特的螺狮粉8 小时前
篮球集训班器具管理系统 - 鸿蒙PC Electron框架完整技术实现指南
前端·javascript·华为·electron·前端框架·开源·鸿蒙
pusheng20258 小时前
IFSJ全英文专访:中国创新力量重塑先进气体感知技术,赋能全球关键基础设施安全
前端·网络·人工智能·物联网·安全
AI_零食9 小时前
番茄钟鸿蒙PC Electron框架完成:状态机、定时器管理与专注力工具设计
前端·javascript·华为·electron·开源·鸿蒙·鸿蒙系统