Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Route is not defined Inertia JS

In my controller, I have a method to redirect to a route:

return Redirect::route('/management');

This is my routes/web.php:

Route::get('/management', function () {
    return Inertia::render('Management');
});

However, it throws an error saying Route [management] not defined.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The Redirect::route() method expects a named route, which you have not defined in your routes/web.php file.

In order to use a named route, you need to change your route to:

Route::get('/management', function () {
    return Inertia::render('Management');
})->name('management'); // added

After that, you can redirect to named routes in Inertia like so:

return Redirect::route('management');

Since we’re using named routes, and not URLs, you should not include the leading / in your route() call.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading