## 问题描述 业务部署到 CentOS 服务器上之后,没有做全面的测试。最近查看 Nginx 日志,发现其中一项业务的某个 API 一直报 405 错误,上网搜索了一下,需要配置 Nginx 来解决这个问题。 ## 解决流程 - 关键词:`nginx options 405` - 解决方案:[Handling OPTIONS request in nginx](https://stackoverflow.com/questions/227939) 关键代码: ``` location / { if ($request_method = OPTIONS ) { add_header Content-Length 0; add_header Content-Type text/plain; return 200; } } ```
问题描述
业务部署到 CentOS 服务器上之后,没有做全面的测试。最近查看 Nginx 日志,发现其中一项业务的某个 API 一直报 405 错误,上网搜索了一下,需要配置 Nginx 来解决这个问题。
解决流程
nginx options 405关键代码: