美文网首页
服务端配置https证书后post请求变成get请求问题

服务端配置https证书后post请求变成get请求问题

作者: 天天想念 | 来源:发表于2021-05-16 13:31 被阅读0次

https现在越来越流行,前几天将部署的网站请求http配置成了https后,发现提供给前端接口所有的post请求变成了get请求。提示如下错误(使用springboot脚手架):

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported

经过查询,我的解决方案是修改Nginx的配置

修改前
server {
        listen 80;
        server_name yourdomain.com; 
        rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。
        location / {
            index index.html index.htm;
        }
    }
修改后
server {
        listen 80;
        server_name yourdomain.com; 
        return 307 https://$host$request_uri;
        location / {
            index index.html index.htm;
        }
    }

相关文章

网友评论

      本文标题:服务端配置https证书后post请求变成get请求问题

      本文链接:https://www.haomeiwen.com/subject/getrjltx.html