And then I created a middleware to redirect to the correct tenant if the user enters one that they are not authorized to access. The middleware does something like this:
It seems that redirects with Inertia::location update the Ziggy state (???) and correctly populate the default parameters, but this is not the case with redirect()->route(...).
IF the redirect is done with redirect()->route('dashboard'), the workaround on the React side is to explicitly set the expected param:
In this case, the tenant param was obtained from the usePage hook (Ziggys defaults !!!), which demonstrates that the default (tenant) parameter is being loaded on the client:
Ziggy version
1.8.1
Laravel version
10.38.2
Description
I defined a Laravel route based on a tenant prefix:
And then I created a middleware to redirect to the correct tenant if the user enters one that they are not authorized to access. The middleware does something like this:
When the redirect is complete, the React SPA throws the following exception:
error: Ziggy error: 'tenant' parameter is required for route 'dashboard'.
But if a change the redirect to:
then no error occurs.
In the React client, the link is:
It seems that redirects with
Inertia::location
update the Ziggy state (???) and correctly populate the default parameters, but this is not the case withredirect()->route(...)
.IF the redirect is done with
redirect()->route('dashboard')
, the workaround on the React side is to explicitly set the expected param:In this case, the
tenant
param was obtained from theusePage
hook (Ziggys defaults !!!), which demonstrates that the default (tenant) parameter is being loaded on the client:So is it a bug or a misunderstanding in using the default parameters?
Thanks in advance for your help and thanks again for the wonderful package!
Ziggy call and context
Ziggy configuration
Route definition