Hey Hunter, good read. I'm really curious how this would work now that NextJS has added support for middleware directly (in v12). Specifically struggling to understand how to do something like withRoles. Ideally I'd want to define something at the route level that indicates which roles are required to access that route, and then the middleware would be able to use that information to guard against that route.
Haven't really found anything that supports this use case. I think I'm just going to have a base middleware that validates that the token, and then use something like your withRoles HOC to validate the roles at the endpoint level.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Hunter, good read. I'm really curious how this would work now that NextJS has added support for middleware directly (in v12). Specifically struggling to understand how to do something like withRoles. Ideally I'd want to define something at the route level that indicates which roles are required to access that route, and then the middleware would be able to use that information to guard against that route.
Haven't really found anything that supports this use case. I think I'm just going to have a base middleware that validates that the token, and then use something like your withRoles HOC to validate the roles at the endpoint level.