Search code examples
phplaravellaravel-nova

Laravel Nova Impersonation - Redirects to / would like to redirect to backend


I'm using the new (as of writing this) Laravel Nova 4.0 and the official impersonation trait / implementation.

When I impersonate a user it redirects to the frontend homepage /. I would like it to redirect to /admin in general. If I can achieve this, I'd really like to have more granular control which users (based on a simple user type) go to which route by default.

I can't find anything in the documentation, looking through the code or other questions asked in Nova threads.


Solution

  • config/nova.php has options as to which URLs you can use when starting/stopping impersonation:

        'impersonation' => [
            // NOTE: change this from the default '/'
            'started' => '/admin',
            'stopped' => '/',
        ],
    

    Because this is loaded as a config file, it's potentially worth noting that you can't use named routes here as the configuration will be bootstrapped in before the routes are defined.