Default route parameters are not populated in Laravel redirects #700
Replies: 1 comment
-
For this particular edge case, a tenant accessing the wrong subdomain, I would suggest keeping |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
As explained in the description.
Beta Was this translation helpful? Give feedback.
All reactions