高源
后端开发
·2023-10-21
#提问# 在开发上传文件接口的的功能遇到了The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.这个跨域问题,证书模式必须是include,网上找了一些资料, 修改nginx配置: add_header 'Access-Control-Allow-Origin' '前端地址'; add_header 'Access-Control-Allow-Credentials' 'true'; location /api/ { proxy_pass http://backend-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; # 其他允许的头部和方法 } 前端axios配置修改: const myAxios: AxiosInstance = axios.create({ withCredentials: false, baseURL: 'https:/xxxxxx.com', }); 改了之后还是不可以,,,不知道有没有大佬遇到过类似的问题,是怎么解决的。 发送请求的方式是这样的 const res = await myAxios.post('/modules/uploadModule', formData);[捂脸]
0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP