laravel

Laravel sanctum change csrf cookie route


How could I change laravel sanctum csrf cookie route to /api/sanctum/csrf-cookie ?

I tried adding this to api.php routes:

use Laravel\Sanctum\Http\Controllers\CsrfCookieController;
Route::get('/sanctum/csrf-cookie', CsrfCookieController::class . '@show')->middleware('web');

But it looks for this controller under app/http/controllers where it doesn't exist.


Solution

  • So if anyone wondering, there should be prefix within config file that is default set to 'sanctum' within a package service provider.

    So if you want to change it to API routes you should go to config/sanctum.php and add 'prefix' => 'api'.