diff --git a/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php b/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php index 45b51d6338f6..1d5ed5ff03c8 100644 --- a/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php @@ -13,6 +13,7 @@ use Illuminate\Foundation\MaintenanceModeManager; use Illuminate\Foundation\Precognition; use Illuminate\Foundation\Vite; +use Illuminate\Http\Client\Factory as HttpFactory; use Illuminate\Http\Request; use Illuminate\Log\Events\MessageLogged; use Illuminate\Support\AggregateServiceProvider; @@ -41,6 +42,7 @@ class FoundationServiceProvider extends AggregateServiceProvider * @var array */ public $singletons = [ + HttpFactory::class => HttpFactory::class, Vite::class => Vite::class, ]; diff --git a/tests/Integration/Http/HttpClientTest.php b/tests/Integration/Http/HttpClientTest.php new file mode 100644 index 000000000000..6c952f195a75 --- /dev/null +++ b/tests/Integration/Http/HttpClientTest.php @@ -0,0 +1,24 @@ + $this->globalMiddleware); + Http::globalRequestMiddleware(fn ($request) => $request->withHeader('User-Agent', 'Example Application/1.0')); + Http::globalRequestMiddleware(fn ($request) => $request->withHeader('User-Agent', 'Example Application/1.0')); + + $this->assertCount(2, Http::getGlobalMiddleware()); + + Facade::clearResolvedInstances(); + + $this->assertCount(2, Http::getGlobalMiddleware()); + } +}