httpbin - 协议调试工具
httpstatuses - 协议状态码查询
httpie - cURL-like tool for humans
Fiddler
gssong
V2EX  ›  HTTP

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

  •  
  •   gssong · Apr 9, 2020 · 4563 views
    This topic created in 2254 days ago, the information mentioned may be changed or developed.

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

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

    8 replies    2022-08-18 22:15:38 +08:00
    ZehaiZhang
        1
    ZehaiZhang  
       Apr 9, 2020
    之前在 Content-Type 踩过坑,mark 看一下这个什么原因
    kkkkkrua
        2
    kkkkkrua  
       Apr 9, 2020
    看下 nginx 配置带不带 / 的问题
    1iuh
        3
    1iuh  
       Apr 9, 2020
    应该是 POST 被 301 了。
    gssong
        4
    gssong  
    OP
       Apr 9, 2020
    nginx 配置 https 的 443 端口,然后在里面写了个 location
    location / {
    proxy_pass http://localhost:8080;
    }
    1iuh
        5
    1iuh  
       Apr 9, 2020
    注意一下 http 和 https 。 有可能是因为服务器做了 http 强制跳转 https 。
    postman 发出的 POST 遇到 301 之后就会变成 GET 。
    gssong
        6
    gssong  
    OP
       Apr 9, 2020
    我试了下确实是这个问题,我在请求前面加个 https://就没问题了,谢谢大佬
    有时候不加 https://也没问题,蛮奇怪的
    Aliencn
        7
    Aliencn  
       Apr 9, 2020   ❤️ 1
    有些客户端遇到 302 跳转的时候会 [私自] 将 POST 转为 GET
    所以后来推出了 307 的状态码来解决此问题
    https://zh.wikipedia.org/wiki/HTTP_307
    LykorisR
        8
    LykorisR  
       Aug 18, 2022
    时隔两年,再来说一下,在 request 的 setting 部分可以设置 Follow original HTTP Method 即可
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1359 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 17:17 · PVG 01:17 · LAX 10:17 · JFK 13:17
    ♥ Do have faith in what you're doing.