V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
gssong
V2EX  ›  HTTP

postman 发送 post 请求,服务器接受到的却是 get 请求

  •  
  •   gssong · 2020-04-09 17:28:25 +08:00 · 3549 次点击
    这是一个创建于 1471 天前的主题,其中的信息可能已经有所发展或是发生改变。

    各位大佬,这是怎么回事儿 TIM 截图 20200409172512.png

    前端测试 post 请求没问题,自己用 postman 测,出现了这个问题

    8 条回复    2022-08-18 22:15:38 +08:00
    ZehaiZhang
        1
    ZehaiZhang  
       2020-04-09 17:33:02 +08:00
    之前在 Content-Type 踩过坑,mark 看一下这个什么原因
    kkkkkrua
        2
    kkkkkrua  
       2020-04-09 17:33:58 +08:00
    看下 nginx 配置带不带 / 的问题
    1iuh
        3
    1iuh  
       2020-04-09 17:39:05 +08:00
    应该是 POST 被 301 了。
    gssong
        4
    gssong  
    OP
       2020-04-09 17:40:48 +08:00
    nginx 配置 https 的 443 端口,然后在里面写了个 location
    location / {
    proxy_pass http://localhost:8080;
    }
    1iuh
        5
    1iuh  
       2020-04-09 17:40:48 +08:00
    注意一下 http 和 https 。 有可能是因为服务器做了 http 强制跳转 https 。
    postman 发出的 POST 遇到 301 之后就会变成 GET 。
    gssong
        6
    gssong  
    OP
       2020-04-09 17:46:41 +08:00
    我试了下确实是这个问题,我在请求前面加个 https://就没问题了,谢谢大佬
    有时候不加 https://也没问题,蛮奇怪的
    Aliencn
        7
    Aliencn  
       2020-04-09 17:46:56 +08:00   ❤️ 1
    有些客户端遇到 302 跳转的时候会 [私自] 将 POST 转为 GET
    所以后来推出了 307 的状态码来解决此问题
    https://zh.wikipedia.org/wiki/HTTP_307
    LykorisR
        8
    LykorisR  
       2022-08-18 22:15:38 +08:00
    时隔两年,再来说一下,在 request 的 setting 部分可以设置 Follow original HTTP Method 即可
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1155 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:19 · PVG 02:19 · LAX 11:19 · JFK 14:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.