-
Notifications
You must be signed in to change notification settings - Fork 269
Description
A very simple issue.
From our login page, we are redirected to admin.dashboard on successful login.
We have a set of route groups defined in config/ziggy.php:
return [
'groups' => [
'basic' => ['login', 'logout', 'password.*', 'guest.*'],
'admin' => ['admin.*', 'profile.*'],
],
]And we show these based on the auth status:
// app.blade.php
<head>
// ...
{{-- Routes --}}
@if(auth()->user())
@routes(['admin', 'basic'])
@else
@routes('basic')
@endif
// ...
</head>The issue is - when we are first logged in, the <script /> block containing Ziggy routes is not re-generated. We get a browser error: Uncaught Error: Ziggy error: route 'admin.dashboard' is not in the route list.
At this point, if we hard refresh the <script /> block is successfully generated again and we now have access to all "auth" routes.
As far as I understand, this would be due to Inertia's internal handling of Navigation (ie. keeping the application shell in place when necessary).
So my question is, how can we force the @routes directive to. re-generate the routes block when we successfully login, as well as when we log out - since all the "auth" routes are now present in the <script/> block on the login page after we click "Log Out".