I’m having hard time to configure nested groups in CI 4. I’m trying to configure the access to routes passing thru a group of filters to authenticate and validate the data that i’m using in the controller.
Here’s a example of the configuration:
$routes->group('api/', ['filter' => 'jwt'], function ($routes) {
$routes->group('', ['filter' => 'scopefilter:test'], function ($routes) {
$routes->post('test', 'ApiTest::index');
});
});
In this case, the only filter that worked is the scopefilter. The jwt is invisible.
The expecting behavior was that the request should pass thru jwt filter and than the scopefilter.
Has anyone already solved this?
2
Answers
I’m going through this case too
According to the CodeIgniter Docs:
As your inner group has no actual route definition, why not insert the filter in the outer group like so:
The filters are getting called in the order they are assigned.