405 Method Not Allowed,CORS跨域,来也自动化OCR接口报错,Nginx处理OPTIONS请求

 nginx 中修改如下

  server {
    listen       15080;
    server_name  localhost;
 
    location /  {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Credentials 'true';
        add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
        add_header Access-Control-Allow-Headers *;
        
        # 如果是预检请求,那么加上允许CORS等请求头后,返回200成功
        if ($request_method = OPTIONS ) {
                return 200;
        }
 
        proxy_pass http://mage.uibot.com.cn;
    }
  }

 

posted @ 2023-05-22 16:22  黑锦鲤  阅读(132)  评论(0编辑  收藏  举报