psr-jwt icon indicating copy to clipboard operation
psr-jwt copied to clipboard

How to apply the middleware globally for all routes?

Open Cahya opened this issue 11 months ago • 0 comments

Hello please help. I'm trying to apply the middleware globally but it fails. Only works if added to each route.

This is how I use the handler:

// The handler.
$jsonHandler = new Json($secretKey, '', ['message' => 'Authorization Failed']);

// The middleware.
$jwtMiddleware = new JwtAuthMiddleware($jsonHandler);

// JWT middleware (applies to all routes)
$app->add($jwtMiddleware);

Thank you!

Cahya avatar Nov 13 '24 10:11 Cahya