-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resorce route middleware not work #611
Comments
what is the error? your message doesn't give enough info on the problem to determine what the cause is. Worth noting that if it can't load your own custom middleware, that's far more likely to be an issue with your application than this package. |
thx for your response. how much the route is accessed, the middleware should be called first, right? but it accesses the route without making the call |
What middleware is listed when you use |
@lindyhopchris sure ok. in the first image, i have the middleware added to route, and the next image, i have the route list, i dont see the middleware added to this route, just i see sanctum middleware but this is in header route group. if i add this middleware to route group, it work. the middleware is 'role_or_permission' from spatie roles and permissions package |
So I think your problem is this: $resource->get('/') That will collide with the JSON:API index route for the resource (i.e. the route that lists all resources for that resource type). The To add that middleware to the resource routes registered by the package, use: $api->resource('bloodTypes')
->controller('BloodTypeController')
->middleware('role_or_permission...'); |
ok, but i dont need assign the route to group route, i need assign to single resource, in the official documentation we have an example, but, this not work, if i put the middleware assign before resource, not work too |
Your use is different though to the example. This won't work:
Because it collides with the JSON:API routes registered for the resource. The example uses a custom route i.e. one that doesn't collide with the JSON:API routes. |
Hi for averyone
Am trying to add a middleware to one of my resource routes but apparently it can't access the middleware when I enter the route:
Some help
The text was updated successfully, but these errors were encountered: