Routing issue with Laravel Nova and a VueJS SPA

Routing issue with Laravel Nova and a VueJS SPA

Aug 27 2018, 14:44 in Web Development

As I was installing Laravel Nova into one of my new projects, which is a full VueJS Single Page Application with vue-router, I encountered a weird issue:

When I headed to the Nova admin panel, everything was empty. The layout is there but the content was not loaded.

I then opened the Chrome Dev Tools and I noticed that all requests going through the route prefix /nova-api/ responded with a 404, or with the base layout of my VueJS SPA.

MMMMHHH - Something's wrong with the routing!

In my routes/web.php file I had this:

Route::get('/{any}', 'HomeController@index')->where('any', '.*');

If you ever build a VueJS SPA with Laravel, you probably have this too into your route files.

So it seems that all /nova-api/ routes fall into this specific route.

We can fix that by updating the regex.

Here is the Solution

Route::get('/{any}', 'HomeController@index')->where('any', '^(?!nova-api).*$');

Now everything should work as expected !

Happy Coding ;)



Disable AdBlock on this domain and offer me a cup of coffee :)