first commit
This commit is contained in:
39
routes/web.php
Normal file
39
routes/web.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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', '.*');
|
||||
Reference in New Issue
Block a user