Filament + Inertia Auth Redirect Not Returning to Original Domain

Hello!

I’m using Filament with the Inertia React starter kit. I’ve disabled the default Filament auth and want to use Inertia/Fortify auth hosted on a separate subdomain (auth.example.com) while Filament is on admin.example.com.

I created a custom middleware to redirect unauthenticated users (disabled default Authenticate):
->authMiddleware([
    // Authenticate::class,
    RedirectToInertiaAuth::class,
])

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;

class RedirectToInertiaAuth
{
    public function handle(Request $request, Closure $next): Response
    {
        if (!Auth::check()) {
            return Inertia::location(route('login'));
        }

        return $next($request);
    }
}


This correctly redirects users to the login page on auth.example.com, but after login, it does not redirect back to the original Filament URL on admin.example.com.

Without any custom middleware, the redirect works, but on the first attempt, the user is not signed in. After refreshing the page, the user is automatically logged in and redirected to /dashboard. Could this be caused by a missing configuration or session issue?

Has anyone successfully handled cross-domain redirects between Filament and Inertia/Fortify? Any suggestions on keeping users returning to the intended Filament page after login?
Was this page helpful?