diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 22c202fd..fdbd5738 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -42,6 +42,7 @@ class Kernel extends HttpKernel 'api' => [ 'throttle:60,1', 'bindings', + \App\Http\Middleware\CheckIfSpaPrototypeIsEnabled::class, ], ]; diff --git a/app/Http/Middleware/CheckIfSpaPrototypeIsEnabled.php b/app/Http/Middleware/CheckIfSpaPrototypeIsEnabled.php new file mode 100644 index 00000000..28d5af22 --- /dev/null +++ b/app/Http/Middleware/CheckIfSpaPrototypeIsEnabled.php @@ -0,0 +1,19 @@ +<?php + +namespace App\Http\Middleware; + +use Closure; +use Illuminate\Http\Request; +use Symfony\Component\HttpFoundation\Response; + +class CheckIfSpaPrototypeIsEnabled +{ + public function handle(Request $request, Closure $next): Response + { + if (!config('app.spa_prototype_enabled')) { + abort(404); + } + + return $next($request); + } +} diff --git a/config/app.php b/config/app.php index 2f562576..50c9fabf 100644 --- a/config/app.php +++ b/config/app.php @@ -227,4 +227,6 @@ */ 'disable_registration' => env('DISABLE_REGISTRATION', false), + + 'spa_prototype_enabled' => env('SPA_PROTOTYPE_ENABLED', true), ]; diff --git a/routes/web.php b/routes/web.php index 14aec035..f7f5673c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,6 +23,7 @@ use App\Http\Controllers\TransactionController; use App\Http\Controllers\TranslationsController; use App\Http\Controllers\VerifyController; +use App\Http\Middleware\CheckIfSpaPrototypeIsEnabled; use Illuminate\Support\Facades\Route; Route::get('/', [IndexController::class, 'index'])->name('index'); @@ -133,6 +134,7 @@ Route::get('/logout', [LogoutController::class, 'index'])->name('logout'); Route::prefix('prototype') + ->middleware(CheckIfSpaPrototypeIsEnabled::class) ->group(function () { Route::get('/', fn () => 'Hello world'); Route::get('/{any}', \App\Http\Controllers\PrototypeController::class)->where('any', '.*');