0
votes

I'm getting this error

Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Illuminate\Routing\Middleware\ThrottleRequests::addHeaders() must be an instance of Symfony\Component\HttpFoundation\Response, null given,

When getting header inside the middleware of Laravel 5.7 Here's my code in the middleware:

public function handle($request, Closure $next)
{
    if($request->header('Authorization')) {
        return $next($request);
    }

    return response()->json([
        'message' => 'Not a valid API request.',
    ]);
}
1

1 Answers

0
votes

My guess would be that the header() function you are calling is not doing what you expect it to do.