grant@clevyr.com's avatar

Catch-All Route at the very end, always

I am using Nova, Jetstream, Spark...a bunch of laravel packages that have their own routes. I am also needing to write a catch all route for a page builder I'm making that will be the very last route checked, even if more routes are added in the future from another 3rd party package.

How can I set the order in which routes are checked? I ran php artisan route:list and my catch-all route is the very last one, but it is still catching routes for things like /nova, /dashboard, /login...

Is something like this even possible?

0 likes
5 replies
grant@clevyr.com's avatar

@martinbean I don't think that will work for what I'm trying to do.

Is there a way to make sure my routes always load last? Or, is there a way to say "continue to the next matching route" from a controller? Ex: The user goes to /nova, I check to see if /nova is in the DB "custom_pages" table (it is not), so the router then continues to the Nova defined routes. I'm not sure how to make the router "continue" though...

Is that even possible?

martinbean's avatar

It’s literally what a fallback route is for.

If a request do not match a route, it’s the very last one to be checked before Laravel reverts to its default 404 exception response.

grant@clevyr.com's avatar

Ope, I understand what you mean now. That does make sense. I was misunderstanding the fallback method. Thanks for your input! That seems to be working for now...

1 like
philkobby's avatar

Seems the fallback only works for GET request is there a to catch on POST and other methods

Please or to participate in this conversation.