0
我有一个相当复杂的应用程序,它使用自定义身份验证中间件。我有一个路由组是这样的:Laravel嵌套路由组逆中间件
Route::group(['prefix' => 'auth', 'middleware' => 'auth'], function() {
Route::get('/', function() {
echo 'private';
});
Route::group(['prefix' => 'public'], function() {
Route::get('/', function() {
echo 'public';
});
})
});
现在auth
中间件将重定向未经过身份验证的所有请求。带有auth
前缀的主群组已通过身份验证。但是,即使用户未通过身份验证,我也希望组public
可以访问。
所以:
http://example.com/auth < must be authenticated
http://example.com/auth/some-sub-page < must be authenticated
http://example.com/auth/public < no need for authentication
那么,有没有办法像'remove-middleware' => 'auth'
添加到嵌套组与public
前缀?或者我会不得不重组我的路线组?