Closed ghost closed 3 years ago
Please share the version of Ziggy you're using, the relevant route definitions from your routes file, the browser/Vue console output of Ziggy.routes
, and some specific examples of the actual code calling Ziggy (and the browser URL when you see this issue).
Ziggy version : "0.9.4"
ziggy.js
"category":{"uri":"categories","methods":["GET","HEAD"],"domain":null},"generated::AS749Bjk5TMefWIe":{"uri":"api\/{fallbackPlaceholder}","methods":["GET","HEAD"],"domain":null},"dashboard":{"uri":"\/","methods":["GET","HEAD"],"domain":null},"store":{"uri":"stores","methods":["GET","HEAD"],"domain":null}
router in laravel
Route::get('categories') ->uses('CategoryController@index') ->name('category'); Route::fallback(function () { abort(404); });
in vuejs when I call route().current()
for URL 'localhost/categories' result is 'generated::AS749Bjk5TMefWIe' instead of 'category'
but when I remove fallback route in laravel router then ziggy return current route name correctly
Update to Ziggy version ^1.0.0
. In v1 we're filtering out generated::
routes and also explicitly placing fallback routes at the very end, so you shouldn't run into this issue.
FWIW, if anyone else still gets this... I ran into this in ziggy version 1 today.
This code broke route().current()
active states in my Jetstream nav links.
Route::fallback(function () {
return Inertia::render('404');
})->name('404');
simply adding .show
made it work properly again:
Route::fallback(function () {
return Inertia::render('404');
})->name('404.show');
Works.
I am using Laravel 8 with fallback in router list, but on vuejs side when I have tried to show the current router with route().current() the result is something like Generate::rrtdusaz that show my fallback URL in ziggy.js, I don't know why but for some routing route().current() work nice and for other ones return fallback URL name. but when I remove the fallback route in laravel router then ziggy shows the current route truly.