Skip to content

Nginx OPTIONS 请求 405 错误 #126

@Dream4ever

Description

@Dream4ever

问题描述

业务部署到 CentOS 服务器上之后,没有做全面的测试。最近查看 Nginx 日志,发现其中一项业务的某个 API 一直报 405 错误,上网搜索了一下,需要配置 Nginx 来解决这个问题。

解决流程

关键代码:

location / {
    if ($request_method = OPTIONS ) {
        add_header Content-Length 0;
        add_header Content-Type text/plain;
        return 200;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Back-endWhere data really come and goServerThe invisible hero

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions