From aa0b93e16b4554c47847f66af7eeb5f27d75a66f Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 29 Oct 2022 03:17:23 -0400 Subject: [PATCH] Run cors middleware for testing routes --- .github/workflows/dusk.yml | 1 - app/Http/Kernel.php | 1 + app/Providers/RouteServiceProvider.php | 23 +++++++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/dusk.yml b/.github/workflows/dusk.yml index 2343bc59a..9f7c7bef9 100644 --- a/.github/workflows/dusk.yml +++ b/.github/workflows/dusk.yml @@ -7,7 +7,6 @@ jobs: env: APP_URL: "http://127.0.0.1:8000" APP_ENV: dusk - APP_CORS_ALLOWED_ORIGINS: "*" DB_USERNAME: root DB_PASSWORD: root MAIL_MAILER: log diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7df1ed2b1..c874d2ed5 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -90,6 +90,7 @@ class Kernel extends HttpKernel 'auth' => Authenticate::class, 'auth.basic' => AuthenticateWithBasicAuth::class, 'auth.session' => AuthenticateSession::class, + 'cors' => HandleCors::class, 'guest' => RedirectIfAuthenticated::class, 'csrf' => VerifyCsrfToken::class, 'throttle' => ThrottleRequests::class, diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 8c39a1c26..e00a9c355 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -118,16 +118,19 @@ class RouteServiceProvider extends ServiceProvider return; } - // Simulate Node Ping - Route::get('/api/system', fn () => [ - 'version' => '1.7.0', - 'kernel_version' => '5.4.0-126-generic', - 'architecture' => 'amd64', - 'os' => 'linux', - 'cpu_count' => 2, - ]); + Route::middleware('cors')->group(function () { - // Simulate Successful Server Creation - Route::post('/api/servers', fn () => []); + // Simulate Node Ping + Route::get('/api/system', fn () => [ + 'version' => '1.7.0', + 'kernel_version' => '5.4.0-126-generic', + 'architecture' => 'amd64', + 'os' => 'linux', + 'cpu_count' => 2, + ]); + + // Simulate Successful Server Creation + Route::post('/api/servers', fn () => []); + }); } }