欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Request header field * is not allowed by Access-Control-Allow-Headers in preflight response

程序员文章站 2022-07-14 23:48:47
...

跨域问题记录:请求 headers里添加自定义header时,出现以下错误

Request header field * is not allowed by Access-Control-Allow-Headers in preflight responseRequest header field * is not allowed by Access-Control-Allow-Headers in preflight response


错误原因   

Request header field * is not allowed by Access-Control-Allow-Headers in preflight response

参考:https://www.cnblogs.com/cc299/p/7339583.html

解决方法如下

nginx  配置 add_header 'Access-Control-Allow-Headers' 添加 自定义header 

add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,access_token';