Files
2025-11-06 06:55:15 +00:00

40 lines
1.2 KiB
PHP

<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
// Route to serve images with CORS headers for Flutter web
Route::get('images/{filename}', function ($filename) {
$path = public_path('uploads/' . $filename);
if (!file_exists($path)) {
abort(404);
}
$file = file_get_contents($path);
$type = mime_content_type($path);
return response($file, 200)
->header('Content-Type', $type)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS')
->header('Access-Control-Allow-Headers', '*')
->header('Access-Control-Expose-Headers', '*')
->header('Access-Control-Max-Age', '86400')
->header('Cache-Control', 'public, max-age=31536000');
})->where('filename', '.*');