From 3f48c0bc7c9fc754e95315add5f32210c2f5856b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez?= Date: Thu, 28 May 2026 21:06:08 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20acceso=20p=C3=BAblico=20a=20im=C3=A1gene?= =?UTF-8?q?s=20de=20storage=20para=20WhatsApp=20y=20navegador?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Mueve la ruta /storage/{path} fuera del middleware de auth para que sea pública; necesario para que los servidores de WhatsApp y el navegador puedan cargar imágenes de promociones sin autenticación - Dockerfile: agrega 'rm -rf public/storage' antes de storage:link para evitar que COPY copie la junction de Windows y deje el symlink roto en el contenedor - Crea .dockerignore: excluye public/storage, .git, .env y artefactos de build del contexto de Docker para builds más limpios y seguros Co-Authored-By: Claude Sonnet 4.6 --- .dockerignore | 8 ++++++++ Dockerfile | 2 +- routes/web.php | 13 +++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9543ce91 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git +.env +node_modules +public/storage +storage/framework/cache +storage/framework/sessions +storage/framework/views +storage/logs diff --git a/Dockerfile b/Dockerfile index ba8090e1..6d4af7ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN mkdir -p storage/framework/sessions storage/framework/views storage/framewor && chmod -R 775 storage bootstrap/cache \ && chown -R nobody:nginx storage bootstrap/cache -RUN php artisan storage:link +RUN rm -rf public/storage && php artisan storage:link COPY nginx.conf /etc/nginx/nginx.conf COPY supervisord.conf /etc/supervisord.conf diff --git a/routes/web.php b/routes/web.php index 0b9395ae..c49e4c9b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,6 +58,12 @@ Route::get('/webhook/whatsapp', [\App\Http\Controllers\WhatsAppWebhookControlle Route::post('/webhook/whatsapp', [\App\Http\Controllers\WhatsAppWebhookController::class, 'handle']) ->withoutMiddleware([\App\Http\Middleware\VerifyCsrfToken::class]); +Route::get('/storage/{path}', function (string $path) { + $fullPath = storage_path('app/public/' . $path); + abort_unless(file_exists($fullPath), 404); + return response()->file($fullPath); +})->where('path', '.*'); + Route::middleware(['auth:sanctum',config('jetstream.auth_session'),'verified', ])->group(function () { @@ -160,12 +166,7 @@ Route::middleware(['auth:sanctum',config('jetstream.auth_session'),'verified', Route::resource('/plantel',PlantelController::class); Route::get('/registros', [CodeController::class,'registros' ])->name('registros'); Route::resource('/role',RoleController::class); - Route::get('/storage/{path}', function ($path) { $fullPath = storage_path('app/public/' . $path); - if (!file_exists($fullPath)) { - abort(404); - } - return response()->file($fullPath); - })->where('path', '.*')->middleware('auth'); + // Route::get('/test-chat', function () { broadcast(new MessageSent('Hola realtime ')); return 'Mensaje enviado';}); Route::resource('/turno',TurnoController::class); Route::resource('/user',UserController::class);