vue nginx upload 405

项目前后端分离,前端用vue,后端用springboot,前后端本地启动时,一个把文件上传到本地的upload接口请求返回正常,但前端打包后放在nginx下部署,upload接口就会出现405,其它的post请求正常。最后在nginx下单独配置了一下upload接口的转发正常了。

location / {
            root   "D:/Chen/baas-web/";
            try_files $uri $uri/ /index.html;
            
            index  index.html index.htm;
            #autoindex on;       #开启nginx目录浏览功能
            autoindex_exact_size off;   #文件大小从KB开始显示
            charset utf-8;          #显示中文
            add_header 'Access-Control-Allow-Origin' '*'; #允许来自所有的访问地址
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS'; #支持请求方式
            add_header 'Access-Control-Allow-Headers' 'Content-Type,*';
        }
        
        location /api/chaincode/upload {
            proxy_method POST;
            proxy_pass   http://**.**.**.**:8999$request_uri;#自己后台地址
            proxy_set_header user_token $http_user_token;
        }

 

posted on 2020-06-12 14:09  墨椟  阅读(1759)  评论(0)    收藏  举报