Laravel URL changes on page load (but the page doesn’t)


In my Laravel 8 app when I go to a route, let’s say example.test/dashboard/user or example.test/dashboard/test the URL the address bar always changes to example.test/dashboard/settings. This behaviour showed up suddenly and I have no idea what it is related to.

In another application, also on Laravel 8, there is similar behaviour however whatever page your navigate to it removes the path. So if you go to example.test/search or example.test/terms it will show example.test in the address bar without the /search or /test (and with any query params removed).

It does stay on the page, so there is no redirect, it’s just that the URL in the address bar is displayed incorrectly and when refreshing the page you then go to that incorrect page obviously.

In routes/web.php I have:

    'as' => 'dashboard.',
    'prefix' => 'dashboard',
    'middleware' => ['verified', 'auth'],
    function () {
        // More routes here...
        Route::get('/settings', [SettingsController::class, 'index'])->name('settings');

Source: Laravel

Leave a Reply