Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 请求头中的 Authorization 字段未被允许 #130

Closed
Dream4ever opened this issue Jan 12, 2021 · 0 comments
Closed

HTTP 请求头中的 Authorization 字段未被允许 #130

Dream4ever opened this issue Jan 12, 2021 · 0 comments
Labels
Back-end Where data really come and go Server The invisible hero

Comments

@Dream4ever
Copy link
Owner

在将 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,总算解决问题了。

@Dream4ever Dream4ever added Back-end Where data really come and go Server The invisible hero labels Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Back-end Where data really come and go Server The invisible hero
Projects
None yet
Development

No branches or pull requests

1 participant