0

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?

sempakonka
  • 35
  • 8
  • Have you added sanctum statefull domains? This SO question helped me with a similar issue https://stackoverflow.com/questions/62269976/laravel-sanctum-auth-issue – dz0nika Dec 12 '22 at 14:19
  • I ended up creating a whole new project and copying the code. Still not sure what caused the problem. – sempakonka Dec 18 '22 at 14:14

0 Answers0