Skip to content

302 Redirect with Got http-client is not re-written as GET request. #1665

@exoup

Description

@exoup

Describe the bug
When making a POST/PUT/non-GET request that returns a 302 redirect utilizing the Got http-client, Thunder Client will not rewrite the request as a GET, frequently causing a 404/error.

When performing the same with Axios, it does rewrite the request as GET. (Which is what the browser and most clients (postman, etc) do.)

To Reproduce
Using the Got http-client, make a request to a POST endpoint that returns a 302 redirect to a GET endpoint.

import { Hono } from "hono";
const app = new Hono();
app.get('/get', (c) => c.text('Hello!'));
app.post('/logout', (c) => c.redirect('/', 302));

Request POST /logout and receive 404 instead of 200.

Expected behavior
By default, other clients (Postman, etc) will typically rewrite the request as GET (default Axios behavior), so you'd receive Hello! from the example above.

Would expect requests made with Got to follow this behavior.
It is the default behavior of Got NOT to do this per HTTP spec and their docs but it can be changed.
It looks like it was attempted to be addressed #388 but was not.

Seems like this could be resolved by setting the methodRewriting boolean to true.

Platform:

  • extension version: v2.33.2

Are you using the free version/paid version/trial:
Free

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions