I am try to create custom route in plugin but get 401, 404

i am try to create custom route in plugin but get 401, 404.

some one can help me. i dont know where i am wrong. i use strapi v5. my config is work on v4 but i try upgrade to v5 is broken :frowning_with_open_mouth:

some one can help me?

This topic has been created from a Discord post (1290528325999267861) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

This is so much a fix as a workaround, but I had a similar issue on one of my content-types. You can manually set the handler like this

         return strapi.controllers['course'].test(ctx);
       },```

i jusst create a one custom route in plugin, what is this file?

routes/index.js where you have handler: ‘course.test’, try replace it with what I put

can u share me one routes in plugin for example?

my vscode yeld error

You still need the controller to be defined in controllers/course.js which is imported in to index.js

is that imported into controllers/index.js?

hmm i dunno then why its not picking up that controller

i thing fix route firt, i dont know why cant create route inplugin

Tbh mate I think theres quite a lot of issue in plugin development. I’ve ran in to plenty of issues that just don’t exist when developing directly in a project

in v4, i config like that but not work in v5 :frowning_with_open_mouth:

ah im still v4

how to install v4 now?,

set version here i think npx create-strapi@ my-strapi-project

<@861468030261395487> I’ve just been battling a similar issue and turns out instead of ‘course’ you need the full uid path so strapi.controllers[‘plugin::mypluginname.course’].test

you can do this to log the names of controllers and then find the one you want / check it is registered properly
console.log(‘Registered controllers:’, strapi.controllers);

<@861468030261395487> if you could wrap your code in a repository (the one in v5) it would be easier to debug

how? i want to create new route in plugin on strapi v5

got it, but it’s not easy to understand your issue without looking at the full codebase of your project

here is my routes on plugin ( i genera from npx @strapi/sdk-plugin init my-strapi-plugin) then i get 401 error

i need help