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

devhoussam123's avatar

Why I'm getting 404 - Not Found while I add {locale} prefix to laravel breeze auth routes?

I have configured Laravel Breeze with localization correctly, but I am encountering a problem when accessing authentication routes like "login" and "register." Despite ensuring that the blade files and all necessary setups are in place, I consistently receive a 404 error.

here is my routes auth URL:

https://my-app.dev/en/login

https://my-app.dev/en/register

I get 404 not found?

routes/web.php

<?php

use App\Http\Controllers\PageController;
use Illuminate\Support\Facades\Route;

// Redirect home with default language yourdomain.com/en/
Route::get('/', function () {
    return redirect(app()->getLocale());
});

Route::prefix('{locale}')
    ->where(['locale' => '[a-zA-Z]{2}'])
    ->middleware('setlocale')
    ->group(function () {
        Route::get('/{slug?}', [PageController::class, 'show'])
            ->name('page')
            ->where('slug', '.*');
        require __DIR__.'/auth.php';
});

routes/auth.php

<?php

use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\RegisteredUserController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Auth Routes
|--------------------------------------------------------------------------
*/

Route::middleware('guest')->group(function () {
    Route::get('register', [RegisteredUserController::class, 'create'])
        ->name('register');

    Route::post('register', [RegisteredUserController::class, 'store']);

    Route::get('login', [AuthenticatedSessionController::class, 'create'])
        ->name('login');

    Route::post('login', [AuthenticatedSessionController::class, 'store']);
    ...
});

SetLocale.php

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;

class SetLocale
{
    /**
     * Handle an incoming request.
     *
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $locale = $request->segment(1);
        $availableLocales = Config::get('app.available_locales');

        if (! in_array($locale, $availableLocales)) {
            $locale = Config::get('app.fallback_locale');
        }

        App::setLocale($locale);
        URL::defaults(['locale' => $locale]);

        return $next($request);
    }
}
0 likes
3 replies
Snapey's avatar

run php artisan route:list

From your question, you want /en/login and not /login so should add the locale prefix to the auth routes also?

devhoussam123's avatar

@Snapey thank you for your reply I already move the require DIR.'/auth.php'; inside route group with {locale} prefix check this out

Route::get('/', function () {
    return redirect(app()->getLocale());
});

Route::prefix('{locale}')
    ->where(['locale' => '[a-zA-Z]{2}'])
    ->middleware('setlocale')
    ->group(function () {
        Route::get('/{slug?}', [PageController::class, 'show'])
            ->name('page')
            ->where('slug', '.*');
        require __DIR__.'/auth.php';
    });

Screenshot

Please or to participate in this conversation.