Почему возвращается 500 ошибка
App.php
public function run()
{
$matcher = new UrlMatcher($this->routes, $this->requestContext);
try {
$this->request->attributes->add($matcher->match($this->request->getPathInfo()));
$this->controller = $this->getController();
$this->arguments = $this->getArguments($this->controller);
$response = $this->executeAction();
} catch (ResourceNotFoundException $exception) {
throw new HandlerException('not found',404);
}
if (!empty($response) && is_object($response)) {
$response->send();
} else {
echo $response;
}
}
AuthorizationMiddleware.php
public function handle(Request $request, \Closure $next)
{
$token = $request->headers->get('Authorization');
$authorization = $request->headers->get('Authorization');
if ($authorization === null) {
throw new \Exception('Authorization required',403);
}
JWT::$leeway = 10;
try {
$decoded = JWT::decode($token, getenv('JWT_SECRET_KEY'), ['HS256']);
set_user_id($decoded->user_id);
} catch (ExpiredException $e) {
throw new \Exception('Provided token is expired', 400);
} catch (SignatureInvalidException $e) {
throw new \Exception('Signature verification failed', 401);
}
return $next($request);
}