In this episode, we look at how you can customize the routes that Laravel Fortify provides out of the box. By default, all of Fortify's routes are hidden away inside your vendor
folder (since they're distributed via Composer), which means you can't just go in and change them. If you try, your changes will get overridden next time you update your dependencies.
First, we discuss the simple case—if all you want is to add a prefix (like /auth/
) to your Fortify routes, you can just update the prefix
option in the Fortify config file. That covers the basics, but what if you want more control?
To get full control over the routes (changing paths like /login
to /sign-in
, or attaching your own middleware or controllers), you need to copy the actual Fortify routes file into your own routes
folder (for example, as routes/Fortify.php
). Then, require that file from your routes/web.php
file. This lets you fully customize each route as you see fit.
However, simply copying them in means you'll have both the default Fortify routes and your new ones registered—so paths like /login
AND your replacement (/sign-in
) will both work. To avoid this, you need to disable Fortify's default route registration. You do this by calling Fortify::ignoreRoutes()
in your service provider (usually in the register
method).
After that, only your customized routes will be active, giving you complete control over your authentication URLs.
So, in summary: copy Fortify's route file into your app, require it, then disable the originals with ignoreRoutes()
. That way, you can easily customize things like URL paths, middleware, and controllers that power your app's authentication!