Laravel auth sanctum causes socket to hang up

364 Views Asked by At

I am trying to use Laravel auth sanctum middelware. Logging in and registering works fine, but when I try to make an authenticated request the socket hangs up, and all requests after that get refused.

Error: connect ECONNREFUSED 127.0.0.1:8000
Error: socket hang up

My protected route:

Route::group(['middleware' => 'auth:sanctum'], function () {
    Route::get('/test', [ApiController::class, 'test']);
});

My simple test method:

public function test(Request $request){
    return "hello world";
}

My test function works fine when I don't authenticate it. It seems like when it is trying to authenticate the request, something goes wrong and the whole Laravel server refuses all requests.

What could be the cause of this?

0

There are 0 best solutions below