zoukankan      html  css  js  c++  java
  • POST请求*设置

    主要是因为post有两次请求,第一次为option,需要单独设置

    user  nginx;
    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
    
        keepalive_timeout  65;
    
        server {
            listen 80;
            server_name upload.myshop.com;
            add_header 'Access-Control-Allow-Origin'  '*';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            location / {
                proxy_pass  http://192.168.0.104:8888;
                if ($request_method = 'OPTIONS') {
                    add_header Access-Control-Allow-Origin  *;
                    add_header Access-Control-Allow-Headers X-Requested-With;
                    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
                    # 解决假请求问题,如果是简单请求则没有这个问题,但这里是上传文件,首次请求为 OPTIONS 方式,实际请求为 POST 方式
                    # Provisional headers are shown.
                    # Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response.
                    add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range;
                    return 200;
                }
            }
        }
    }
    
  • 相关阅读:
    CAP分布式
    专职DBA-MySQL数据库开篇
    os.sep
    DocStrings
    Python如何获取脚本的参数
    LVM基础命令
    VoAndEntityTrans
    短信倒计时
    springboot在eclipse上搭建项目一(无页面)
    springboot问题
  • 原文地址:https://www.cnblogs.com/zhenhunfan2/p/13725760.html
Copyright © 2011-2022 走看看