I’m on Strapi 4.12.4. Currently trying to extend the users-permissions plugin in a similar manner.
extensions/users-permissions/strapi-server.ts:
export default (plugin) => {
plugin.controllers.user.testRoute = (ctx) => {
ctx.body = {
message: "Hello World!",
};
};
plugin.routes["content-api"].routes.push({
method: "GET",
path: "/user/test-route",
handler: "user.testRoute",
config: {
prefix: "",
},
});
return plugin;
};
When I try to access http://localhost:1337/user/test-route, I get a 404 error. The exported function with the plugin argument is being called. I’ve checked that with a console.log. The plugin object is also present. Even when I enter a wrong handler for the newly-created route, I get a server error, preventing the start of the app. So to me this means that the handler is registered, along with the route. I’ve also tried doing it in JavaScript instead of TypeScript. Same outcome.
The question here is - why it gives me the 404 error. ![]()
Can somebody help?