mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 11:20:53 +08:00
fix(runtime): force app_url/force_https per-request via middlewar
This commit is contained in:
@@ -37,6 +37,7 @@ class Kernel extends HttpKernel
|
||||
// \Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
// \App\Http\Middleware\VerifyCsrfToken::class,
|
||||
// \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\ApplyRuntimeSettings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
@@ -46,6 +47,7 @@ class Kernel extends HttpKernel
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
// \Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
// \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\ApplyRuntimeSettings::class,
|
||||
\App\Http\Middleware\ForceJson::class,
|
||||
\App\Http\Middleware\Language::class,
|
||||
'bindings',
|
||||
|
||||
25
app/Http/Middleware/ApplyRuntimeSettings.php
Normal file
25
app/Http/Middleware/ApplyRuntimeSettings.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class ApplyRuntimeSettings
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$appUrl = admin_setting('app_url');
|
||||
if (is_string($appUrl) && $appUrl !== '') {
|
||||
URL::forceRootUrl($appUrl);
|
||||
}
|
||||
|
||||
if ((bool) admin_setting('force_https', false)) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user