Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lortex's avatar

Proper way to override Jetstream/Fortify auth routes?

Hi everyone! What is the proper way to override Fortify routes? (project-folder/vendor/laravel/fortify/routes/routes.php)

For example, I want my login form to appear at the 'myadminlogin' route instead of 'login' route.

0 likes
17 replies
rodrigo.pedra's avatar
Level 56

On your FortifyServiceProvider boot method add this:

// ./app/Providers/FortifyServiceProvider.php

    public function boot()
    {
        Fortify::ignoreRoutes(); // <<< ADDED THIS LINE

        // Below is the default configuration that comes with this provider
        // If you changed it, you can keep your changes
        Fortify::createUsersUsing(CreateNewUser::class);
        Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
        Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
    }

This will tell Fortify to ignore its built-in route definitions.

Then copy Fortify's routes definitions to your ./routes/web.php file.

The package routes definitions are located in a file located at ./vendor/laravel/fortify/routes/routes.php from your project's root directory.

Do not change the routes inside this file.

Again, you should copy them to your local ./routes/web.php. Changes made inside the vendors folder are discarded when you update your project's dependencies.

You'll need to keep the controllers imports. But you can skip the route group as it only wraps inside the web middleware stack which your ./routes/web.php file already is wrapped around.

Then you can change the routes' paths to fit your needs.

27 likes
juslintek's avatar

It does not work, because Laravel\\Fortify\\FortifyServiceProvider::boot(), is executed first... It registers duplicated routes...

But it works if you add Fortify::ignoreRoutes(); to ./bootstrap/app.php. Then the static property is preset on time. :-)

5 likes
fabiancz's avatar

Fortify::ignoreRoutes(); should be placed in register method of FortifyServiceProvider.

21 likes
nyce's avatar

@juslintek I agree with you. Putting it in the FortifyServiceProvider() doesn't work. An alternative is to go to the config/fortify.php file, and to switch off options individually in the 'features' => [] array (this option already suggested elsewhere).

I don't quite understand how the documentation can get this so wrong. And moreover, I don't understand how everyone else can agree along with the documentation when this solution clearly doesn't work!! It must be me that's doing something wrong, no? Can someone tell me what?

Lortex's avatar

Thanks for your clear answer. You helped me a lot!

2 likes
icemancast's avatar

You should be able to modify that in config/fortify.php there is a path setting there. I was able to disable my register route there as the app I am doing doesn't require register just login.

1 like
Lars02_'s avatar

@icemancast This is what I was looking for :D

For all other people go down to 'features' and just comment out what you don't want

1 like
icemancast's avatar

@Lars02_ yeah thanks should have been more specific.

config/fortify.php

'features' => [
        // Features::registration(),      <-------- comment out this line.
        Features::resetPasswords(),
        // Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ]),
    ],
2 likes
AcriCAA's avatar

Hi,

Thank you for this, it was very helpful. @rodrigo.pedra, it seems that if I just wanted to modify the fortify web routes for user registration (to add a 'fortify' prefix to the route and require 'auth' to register instead of the default 'guest', I could just copy those over to my web.php routes file and everything else should work fine. I am testing that now, seems to work but please let me know if you think there's any issues I am missing:

// Registration...
 
        Route::get('fortify/register', [RegisteredUserController::class, 'create'])
                ->middleware(['auth'])
                ->name('register');
    

        Route::post('fortify/register', [RegisteredUserController::class, 'store'])
            ->middleware(['auth']);
    

Thanks again.

1 like
Stockholm's avatar

I wanted to replace the Jetstream registration form with a Livewire component. It was enough to disable Features::registration() in config/fortify.php. Then I added my own routes to my Livewire component.

1 like
ACH's avatar

I need to do similar: I want to use roles so I installed Spatie/laravel-permission. I then copied views/auth/register.blade.php to newuser.blade.php in same folder and modified it. In newuser.blade.php I have the following form with post:

		<form method="POST" action="{{ route('newuser') }}">

In web.php I added the following:

Route::get('auth/newuser', [RegisteredUserController::class, 'create'])
        ->middleware(['auth'])
        ->name('newuser');;

Route::post('auth/newuser', [RegisteredUserController::class, 'store'])
        ->middleware(['auth']);

When trying to register new user I get error message "404 | Not found". What am I missing?

mrvbltzr's avatar

@ACH you should remove the auth middleware in your registration route. Auth middleware is only used to check if the user is logged-in.

maxss's avatar

No need to override all the routes with Fortify::ignoreRoutes(); if уоu only want to modify one route. So for your example, in web.php routes just add:

Route::get(RoutePath::for('login', '/myadminlogin'), [Laravel\Fortify\Http\Controllers\AuthenticatedSessionController::class, 'create'])
    ->middleware(['guest:'.config('fortify.guard')])
    ->name('login');

Which уоu can copy from the Fortify routes.php files. You can even copy the controller from AuthenticatedSessionController to your own Http/Controllers folder and modify it.

1 like

Please or to participate in this conversation.