Closed catabozan closed 2 years ago
Looks like a bug - if the request's route()
method can return null
, we should handle that gracefully rather than causing another error. Thanks for reporting.
Tagged the laravel-json-api/exceptions
package with the fix as v1.1.1
.
To upgrade:
composer up laravel-json-api/*
Laravel: 9 laravel-json-api: 2.4
I have implemented some API endpoints to my app that also has web routes.
The problem occurs when visiting non-existing web routes: instead of getting the
404 not found
page, I get a blank page with a 500 response. The problem occurs inlaravel-json-api/exceptions/src/ExceptionParser::acceptsMiddleware
on line 249.Because
$request->route()
returnsnull
.I recently installed the
stancl/tenancy
package that adds multitenancy to my app, and divides the routes into central routes (available without being a tenant), and tenancy routes. I don't know if this is relevant but thestancl/tenancy
package adds its own middleware before all other middleware. The weird part is that if for example I have a tenant specific route (let's say/home
) and I try to access it without being in a tenant context, I get the 404 error (correct behavior). But if I try to access a route that is not defined as a tenant nor domain specific route (it does not exist anywhere), I get the error mentioned above.Is this a package related problem?
Maybe change the
acceptsMiddleware()
method like thisOr is there something wrong with my setup?
If this is the case, do you know what could be the cause of the issue, or where should I ask for help?
This is in my
RouteServiceProvider
: