diff --git a/src/Illuminate/Filesystem/FilesystemServiceProvider.php b/src/Illuminate/Filesystem/FilesystemServiceProvider.php index 28fe5f60b23a..5fe6b9e531be 100644 --- a/src/Illuminate/Filesystem/FilesystemServiceProvider.php +++ b/src/Illuminate/Filesystem/FilesystemServiceProvider.php @@ -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); });