skip to Main Content

I define a route in my routes/api.php

Route::post('Client/LoginClient',[ClientController::class,
function(Request $request) {
    
}]);

and when I post something to the route, I encounter this error:

419 Page Expired

How could I post data to the route?

Edit #1:
I am posting data via Postman.

2

Answers


  1. Chosen as BEST ANSWER

    In VerifyCsrfToken class, I added "*" to the except array, and the problem is solved.

    class VerifyCsrfToken extends Middleware
    {
        /**
         * The URIs that should be excluded from CSRF verification.
         *
         * @var array<int, string>
         */
        protected $except = [
            "*"
        ];
    }
    

    But, I do not know what CSRF verification is?


  2. If you don’t want to use CSRF protection for this particular route, you can exclude it from CSRF protection by adding the route to the $except property in the VerifyCsrfToken middleware.

    Open the AppHttpMiddlewareVerifyCsrfToken class and add your route to the $except array.

    protected $except = [
        'Client/LoginClient',
    ];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search