The issue(ERR_TOO_MANY_REDIRECTS) related to the mcamara/laravel-localization package

15 Views Asked by At

I use mcamara/laravel-localization package to add a locale segment to all URLs. I added a route group in the web.php:

Route::group(
    [
        'prefix' => LaravelLocalization::setLocale(),
        'middleware' => [
            'localize', // \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes
            'localeSessionRedirect', // \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect
            'localizationRedirect', // \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter
            'localeViewPath', // \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath
        ],
    ], function () {
      Route::get('/', [HomeController::class, 'home'])->name('home');
      Route::get('currencies', 'currencies')->name('currencies');
      /* Other routes ... */
});
  • When accessing the home page konoha.com/fr, it works correctly (status code 200)

  • On the home page, I fetch(konoha.com/fr/currencies) in a JS file, the flow happened:

    • konoha.com/fr/currencies (302 Found (from disk cache), Referrer-Policy: no-referrer-when-downgrade)
    • konoha.com/fr/currencies (301 Moved Permanently (from disk cache), Referrer-Policy: no-referrer-when-downgrade)
    • (failed)net::ERR_TOO_MANY_REDIRECTS
  • Commented the line "#add_header Referrer-Policy "no-referrer-when-downgrade";" in include.headers

  • Also added these middleware (localize, localeSessionRedirect, localizationRedirect, localeViewPath) in the middleware 'web' in RouteServiceProvidor. But still got the same issue. So, please help to check this issue. Thanks!

0

There are 0 best solutions below