From c0d0d070a8a483ba0e86d303fca39be724713e80 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 31 Jul 2026 10:50:06 +0300 Subject: [PATCH] add me endpoint --- backend/.env.example | 1 + .../app/Http/Controllers/AuthController.php | 23 +++++++++++++++++++ backend/bootstrap/app.php | 1 + backend/config/cors.php | 22 ++++++++++++++++++ backend/routes/api.php | 9 ++++++++ 5 files changed, 56 insertions(+) create mode 100644 backend/app/Http/Controllers/AuthController.php create mode 100644 backend/config/cors.php create mode 100644 backend/routes/api.php diff --git a/backend/.env.example b/backend/.env.example index c3214a6..027ae21 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -3,6 +3,7 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=https://localhost:8000 +FRONTEND_URL=https://localhost:5173 APP_LOCALE=en APP_FALLBACK_LOCALE=en diff --git a/backend/app/Http/Controllers/AuthController.php b/backend/app/Http/Controllers/AuthController.php new file mode 100644 index 0000000..de82e1a --- /dev/null +++ b/backend/app/Http/Controllers/AuthController.php @@ -0,0 +1,23 @@ +attributes->get('user'); + + return new JsonResponse([ + 'user' => [ + 'id' => $user->getId(), + 'email' => $user->getEmail()->value(), + ], + ]); + } +} diff --git a/backend/bootstrap/app.php b/backend/bootstrap/app.php index 324b7c2..141b221 100644 --- a/backend/bootstrap/app.php +++ b/backend/bootstrap/app.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) diff --git a/backend/config/cors.php b/backend/config/cors.php new file mode 100644 index 0000000..5189eb1 --- /dev/null +++ b/backend/config/cors.php @@ -0,0 +1,22 @@ + ['api/*'], + 'allowed_methods' => ['*'], + 'allowed_origins' => $allowedOrigins, + 'allowed_origins_patterns' => [], + 'allowed_headers' => ['*'], + 'exposed_headers' => [], + 'max_age' => 0, + 'supports_credentials' => true, +]; diff --git a/backend/routes/api.php b/backend/routes/api.php new file mode 100644 index 0000000..d8fba04 --- /dev/null +++ b/backend/routes/api.php @@ -0,0 +1,9 @@ +group(function (): void { + Route::get('/me', [AuthController::class, 'me']); +});