diff --git a/routes/web.php b/routes/web.php index 4a72da16..bbf60395 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ exists($r2Path)) { + abort(404); + } + + $mime = Storage::disk('r2')->mimeType($r2Path); + $stream = Storage::disk('r2')->readStream($r2Path); + + return response()->stream(function () use ($stream) { + fpassthru($stream); + if (is_resource($stream)) { + fclose($stream); + } + }, 200, [ + 'Content-Type' => $mime, + 'Cache-Control' => 'public, max-age=86400', + ]); +})->where('path', '.*'); + // Swagger 설정 Route::get('/docs/api-docs.json', function () { return response()->file(storage_path('api-docs/api-docs.json'));