Laravel 11 Jetstream inertia redirect issue after closing browser tab and revisiting site

lmd

Lester MacDonald

Posted on August 28, 2024

Laravel 11 Jetstream inertia redirect issue after closing browser tab and revisiting site

Hi everyone, I am having a redirect issue when closing the browser tab without closing the browser and revisiting the site. I get redirected to Dashboard.

This is the normal behavior however I have changed my home path to a view called timeline.

// config\fortify.php

'home' => '/timeline',
Enter fullscreen mode Exit fullscreen mode

This is my /routes/web.php

<?php

use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use App\Http\Controllers\TimelineController;
use App\Http\Controllers\DashboardController;

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

// A dynamic way to change the robots.txt depending on what environment your in.
Route::get('/robots.txt', function () {
    if (app()->environment('production')) {
        return response("User-agent: *\nDisallow:", 200, ['Content-Type' => 'text/plain']);
    } else {
        return response("User-agent: *\nDisallow: /", 200, ['Content-Type' => 'text/plain']);
    }
});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
])->group(function () {
    Route::get('/timeline', [TimelineController::class, 'index'])->name('timeline');
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
});

Enter fullscreen mode Exit fullscreen mode

With the help of ChatGPT I tried to narrow down where this redirect is happening with no luck. I'm guessing the session has something to do with it. It's a fresh install other than creating a new timeline.vue and redirecting the "/" route to the login page.

Any help would be appreciated. Thanks.

💖 💪 🙅 🚩
lmd
Lester MacDonald

Posted on August 28, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related