Speeding Up Laravel Tests with tmpfs (MySQL in RAM)
If your Laravel test suite is painfully slow and does a lot of database work (multi-tenancy, migrations, seeding), the bottleneck is almost…
When building a multi-language Laravel application with Jetstream and Fortify, you might notice that the authentication, profile, and team management routes don't automatically inherit your localization configuration. Here's how to fix that and ensure all your routes support both language URL prefixes and localization middleware.
By default, Jetstream and Fortify automatically register their routes during the application bootstrap process. This means these routes are registered before you can wrap them in your localization group. As a result, URLs like /login, /register, /user/profile, and team management pages won't have language prefixes like /en/login or /de/register, nor will they be processed by your localization middleware.
The solution involves three simple steps:
First, modify your JetstreamServiceProvider and FortifyServiceProvider to prevent automatic route registration:
// app/Providers/JetstreamServiceProvider.php
public function register()
{
Jetstream::ignoreRoutes();
}
// app/Providers/FortifyServiceProvider.php
public function register()
{
Fortify::ignoreRoutes();
}
Now, update your routes/web.php file to import the Jetstream and Fortify routes within a route group that includes both the language prefix and localization middleware:
<?php
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
Route::group([
'prefix' => LaravelLocalization::setLocale(), // Adds language code to URL
'middleware' => ['localize'] // Handles locale detection and setting
], function () {
// Import Jetstream routes
require base_path('vendor/laravel/jetstream/routes/inertia.php');
// Import Fortify routes
require base_path('vendor/laravel/fortify/routes/routes.php');
// Your other routes...
});
Now all your routes, including authentication, profile management, and team management pages, will have:
For example:
/en/login/de/register/fr/user/profile/es/teams/createGive Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com