-
Notifications
You must be signed in to change notification settings - Fork 6
HTTP 请求头中的 Authorization 字段未被允许 #130
Copy link
Copy link
Closed
Labels
Back-endWhere data really come and goWhere data really come and goServerThe invisible heroThe invisible hero
Description
在将 API 程序由 Windows 迁移到 CentOS 并由 Nginx 进行反向代理之后,先后解决了 Nginx OPTIONS 请求 405 错误 和 Nginx 不允许跨域请求 这两个问题,但是浏览器中访问的页面调用 API 时,又报下面的错误:
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response
仔细看了一下报错信息,大意是说 HTTP 请求头中的 Authorization 字段未被允许。
上网搜索了一下报错信息 + nginx,按照链接 Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response. (nginx) 中的方法,在 if ($request_method = OPTIONS ) 配置段的 add_header Access-Control-Allow-Headers 这一行中,增加了 Authorization 字段,然后重启了 Nginx,总算解决问题了。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Back-endWhere data really come and goWhere data really come and goServerThe invisible heroThe invisible hero