Hi
I’m trying to create a custom endpoint (/suggested-users) extending from users-permissions.
I tried a few things:
Create a User.js on the controller folder (extensions/users-permissions/controllers/Users.js) and then async suggested-users(ctx) => return 'Example',then I gave permissions to public and authenticated. (Error 500, error CastError: Cast to ObjectId failed for value “suggested-users” at path “_id” for model “user”)
Then I try to extend the routes files, with only /suggested-users, and later, with all the routes of the plugin + /suggested-users (But error Error creating endpoint get /suggested-users: handler not found "userspermissions.suggestedusers") (same error)
I try to create another controller, but trying to use the same route.js
I have been overriding some files from users-permission plugin, but never extend
Keep in mind, that first part of the handler is the Filename. You mentioned that you created a Users.js file with controller suggestedusers, but from routes you are accessing the userpermissions.js file, so it doesn’t contain your custom controller suggestedusers.
I did this exactly and the routes aren’t showing up in the role permissions config. When I try adding the route directly in the strapi-server.js file like this instead:
No it doesn’t, it solves a completely different problem. That video shows you how to make a custom endpoint for a custom content-type, not how to add a controller to a content-type that is included as part of a plugin