Skip to content

Commit 9e41b60

Browse files
committed
Don’t register routes when StageFront is disabled
1 parent 0f29b70 commit 9e41b60

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

routes/routes.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
use CodeZero\StageFront\Controllers\StageFrontController;
44

5-
Route::group(['middleware' => config('stagefront.middleware')], function () {
5+
if (config('stagefront.enabled') === true) {
66

7-
$url = config('stagefront.url');
7+
Route::group(['middleware' => config('stagefront.middleware')], function () {
88

9-
Route::get($url, StageFrontController::class.'@create');
10-
Route::post($url, StageFrontController::class.'@store');
9+
$url = config('stagefront.url');
1110

12-
});
11+
Route::get($url, StageFrontController::class.'@create');
12+
Route::post($url, StageFrontController::class.'@store');
13+
14+
});
15+
16+
}

src/Middleware/RedirectIfStageFrontIsEnabled.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@ public function handle($request, Closure $next)
1919
$disabled = ! config('stagefront.enabled', false);
2020
$unlocked = session('stagefront.unlocked', false);
2121
$stageFrontUrl = trim(config('stagefront.url'), '/');
22-
$requestIsStageFront = $request->is($stageFrontUrl);
2322

24-
if ($disabled && $requestIsStageFront) {
25-
abort(404);
26-
}
27-
28-
if ($unlocked || $disabled || $requestIsStageFront) {
23+
if ($unlocked || $disabled || $request->is($stageFrontUrl)) {
2924
return $next($request);
3025
}
3126

0 commit comments

Comments
 (0)