-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathapp.php
More file actions
76 lines (65 loc) · 2.63 KB
/
app.php
File metadata and controls
76 lines (65 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
use App\Http\Middleware\ComposerTokenAuth;
use App\Http\Middleware\HandleAppearance;
use App\Http\Middleware\HandleInertiaRequests;
use App\Http\Middleware\TrackOrganizationAccess;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Sentry\Laravel\Integration;
use Symfony\Component\HttpFoundation\Response;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
channels: __DIR__.'/../routes/channels.php',
health: '/up',
then: function () {
Route::middleware('api')
->group(base_path('routes/composer.php'));
Route::middleware('api')
->group(base_path('routes/webhooks.php'));
},
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->encryptCookies(except: ['appearance', 'sidebar_state']);
$trustedProxies = explode(',', env('TRUSTED_PROXIES', ''));
if ($trustedProxies === ['*']) {
$trustedProxies = '*';
}
$middleware->trustProxies(at: $trustedProxies);
$middleware->web(append: [
HandleAppearance::class,
HandleInertiaRequests::class,
AddLinkHeadersForPreloadedAssets::class,
]);
$middleware->alias([
'composer.token' => ComposerTokenAuth::class,
'track.organization' => TrackOrganizationAccess::class,
]);
})
->withCommands([
__DIR__.'/../app/Domains/Repository/Commands',
__DIR__.'/../app/Domains/Token/Commands',
__DIR__.'/../app/Domains/Mirror/Commands',
__DIR__.'/../app/Domains/Security/Commands',
])
->withExceptions(function (Exceptions $exceptions): void {
Integration::handles($exceptions);
$exceptions->respond(function (Response $response) {
if (app()->hasDebugModeEnabled() && $response->getStatusCode() === 500) {
return $response;
}
if (in_array($response->getStatusCode(), [403, 404, 500, 503]) && ! request()->expectsJson()) {
return Inertia::render('error', [
'status' => $response->getStatusCode(),
])
->toResponse(request())
->setStatusCode($response->getStatusCode());
}
return $response;
});
})->create();