在laravel 9中,我在线路上看到了Fortify认证
GET|HEAD login ................................................................................................................................................... login › Laravel\Fortify › AuthenticatedSessionController@create
POST login .............................................................................................................................. generated::kNTXAE1j2bp8Zq09 › Laravel\Fortify › AuthenticatedSessionController@store我的登录页面由“/login”url打开。
如何使这个登录名为“/admin/ login”url?
像以前一样保留所有的Fortify功能?
谢谢!
发布于 2022-04-11 12:12:27
在FortifyServiceProvider中的boot()方法中,应该添加
Fortify::ignoreRoutes();在默认配置之前。
它将告诉Fortify忽略内置的路线。
然后,您应该将Fortify的路由(./vendor/laravel/fortify/routes/routes.php)复制到自己的路由(./routes/web.php)文件中。
然后,在您的web.php文件中,您可以相应地进行更改。
发布于 2022-10-27 15:40:53
就我的情况而言:
Laravel Framework 9.25.1和"laravel/jetstream":"^2.11“,其中包含"laravel/fortify":"^1.13.3”
/admin可以添加config/fortify.php文件。在这个文件中找到prefix键并添加前缀。例子:return [
// code...
'prefix' => 'admin',
// code...
];app/Providers/FortifyServiceProvider.php for register方法:public function register()
{
Fortify::ignoreRoutes(); // add this string
// ... next code
}对于boot方法:
public function boot()
{
Route::group([
'namespace' => 'Laravel\Fortify\Http\Controllers',
'domain' => config('fortify.domain', null),
'prefix' => config('fortify.prefix'),
], function () {
$this->loadRoutesFrom(base_path('routes/fortify.php'));
}); // this closure
// ... next code
}vendor/laravel/fortify/routes/routes.php复制到routes/fortify.php并更改此文件中的路由。在app/Providers/FortifyServiceProvider@boot.中的闭包中指定了相同的路径
https://stackoverflow.com/questions/71827446
复制相似问题