Skip to content

HTTP Client Middleware not working #44897

@aniket-magadum

Description

@aniket-magadum
  • Laravel Version: 9.39.0
  • PHP Version: 8.0.24
  • Database Driver & Version:8.0.31

Description:

I am trying to execute the sample code provided here https://laravel.com/docs/9.x/http-client#guzzle-middleware

$response = Http::withMiddleware(
        GuzzleHttp\Middleware::mapRequest(function (Psr\Http\Message\RequestInterface $request) {
            $request->withHeader('X-Example', 'Value');
            return $request;
        })
    )->get('https://example.com');

But when I check the request inside of laravel telescope it seems that the request is not getting modified using this middleware.

image

image

I even tried changing the request method to post but that also did not seem to work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions