sbine / nova-route-viewer

Route viewer tool for Laravel Nova
MIT License
59 stars 9 forks source link

this.router.filter is not a function #12

Closed bcorcoran closed 4 years ago

bcorcoran commented 4 years ago

Laravel 6.3.0 Laravel Nova 2.5.0 PHP 7.3

I'm getting a javascript error when attempting to view the Router Viewer. I get no results (I can successfully see them using php artisan route:list and this.router.filter is not a function error in the browser console.

sbine commented 4 years ago

The route viewer code doesn't contain any instances of this.router.filter. The closest is this.routes.filter, but since this.routes is instantiated to an empty array, the filter function should always be available.

Can you provide a stack trace, and the full line or section of code causing the error?

bcorcoran commented 4 years ago

Well, I don't have dev mode enabled on Nova, but:

Screen Shot 2019-10-24 at 00 40 42

If you can tell me what you'd like me to try, I'm happy to try it, but I don't have a lot of time to debug at the moment.

bcorcoran commented 4 years ago

Actually I just looked again and ran Nova.request().get('/nova-vendor/route-viewer/routes').then(response => { console.log(response.data) }) in the console and it gave me my index page... meaning the routes aren't working properly. The route is listed in php artisan route:list but I suspect there's something going on with Sbine\RouteViewer\Http\Controllers\Api@getRoutes

sbine commented 4 years ago

Two things that could help:

  1. Check the Network tab to see what the HTTP status code and/or error message was on the failed request to /nova-vendor/route-viewer/routes
  2. Check your Laravel application log (usually storage/logs/laravel.log) for an error message
bcorcoran commented 4 years ago

OK, disregard this. I am running an SPA and I had the following rule:

Route::any('{all}', function() { return view('index'); })
    ->middleware('auth')
    ->where(['all' => '^(?!admin|nova-api).*$']);

I added nova-vendor to the list of exceptions and it's working just fine. Sorry for the trouble!