RicardoAbel's avatar

Laravel 11, 419 Page Expired

Im using Laravel 11 with Postman to test my API. im planning to use VueJS later.

I created a Authentication Controller, and im using MySQL database, I also migrated everything (Laravel 11 migrations)

Now when I send a request to my route which is /register from postman I get 419 page expired.

     use Illuminate\Foundation\Application;
     use Illuminate\Foundation\Configuration\Exceptions;
     use Illuminate\Foundation\Configuration\Middleware;


     return Application::configure(basePath: dirname(__DIR__))
         ->withRouting(
          web: __DIR__ . '/../routes/web.php',
          api: __DIR__ . '/../routes/api.php',
          commands: __DIR__ . '/../routes/console.php',
          health: '/up',
      )
      ->withMiddleware(function (Middleware $middleware) {
      })
     ->withExceptions(function (Exceptions $exceptions) {
     })->create();

web.php

    Route::post('/register', [\App\Http\Controllers\TestController::class, 'register']);

    Route::post('/login', [\App\Http\Controllers\TestController::class, 'login']);

also I would like to mention that i send a pre-request to /sanctum/csrf-cookie first.

   pm.sendRequest({
     url: "http://localhost:9000/sanctum/csrf-cookie",
     method: "GET"
   }, function(error, response) {
       if (!error) {
        const xsrfToken = pm.cookies.get("XSRF-TOKEN");
        pm.collectionVariables.set("xsrf-cookie", xsrfToken);
   }
   });
0 likes
1 reply
Snapey's avatar

what are you sending with postman? cookie or token?

Please or to participate in this conversation.