Skip to content

Commit

Permalink
[11.x] Fixes out of memory issue running route:cache with ServeFile
Browse files Browse the repository at this point in the history
fixes #52779

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 13, 2024
1 parent 042c267 commit 146c275
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Illuminate/Filesystem/FilesystemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ protected function serveFiles()
continue;
}

$this->app->booted(function () use ($disk, $config) {
$this->app->booted(function ($app) use ($disk, $config) {
$uri = isset($config['url'])
? rtrim(parse_url($config['url'])['path'], '/')
: '/storage';

Route::get($uri.'/{path}', function (Request $request, string $path) use ($disk, $config) {
$isProduction = $app->isProduction();

Route::get($uri.'/{path}', function (Request $request, string $path) use ($disk, $config, $isProduction) {
return (new ServeFile(
$disk,
$config,
$this->app->isProduction()
$isProduction
))($request, $path);
})->where('path', '.*')->name('storage.'.$disk);
});
Expand Down

0 comments on commit 146c275

Please sign in to comment.