im creating a simple CRUD for my internship test as a backend. the test only about API. however, i faced challenges using laravel 11. i cannot access the route in api.php in postman, it says 404 not found.
<?php
use IlluminateHttpRequest;
use IlluminateSupportFacadesApp;
use IlluminateSupportFacadesRoute;
use AppHttpControllersAuthController;
use AppHttpControllersDivisionController;
use AppHttpControllersEmployeeController;
Route::post('/login', [AuthController::class, 'login']);
Route::get('/divisions', [DivisionController::class, 'index']);
Route::get('/employee', [EmployeeController::class, 'index']);
Route::post('/employee', [EmployeeController::class, 'store']);
Route::put('/employee/{id}', [EmployeeController::class,'update']);
i already tried to add config in app.php in bootstrap folder and RouteServiceProvider, but none of it worked.
<?php
use IlluminateFoundationApplication;
use IlluminateFoundationConfigurationExceptions;
use IlluminateFoundationConfigurationMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->group('api', [
IlluminateRoutingMiddlewareThrottleRequests::class,
IlluminateRoutingMiddlewareSubstituteBindings::class,
]);
$middleware->validateCsrfTokens(except: [
'api/*', //Menonaktifkan CSRF untuk semua rute API
]);
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
im so clueless about this problem and i already tried bunch of solutions but nothing worked. anyone had idea what happened?