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
…#52781)

fixes #52779

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone authored Sep 13, 2024
1 parent 54cf9db commit a9a080f
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 @@ -88,16 +88,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 a9a080f

Please sign in to comment.