I am using strapi V4. I have created the custom plugin where I have defined some routes in the src/plugins/{plugin_id}/server/routes/index.js
I want to authenticate these endpoints with the API token but the problem is that when I generate the token, those routes are not listed out there which fails the authentication on those routes with the API token.
Any idea on how can I solve this?
NOTE: those endpoints are accessible when set auth:false
which indicates that plugin configuration is correct.
There are two different route types (admin and content-api). API tokens and U&P only work on content-api routes, not admin.
You can create content-api routes from your custom plugin with the following syntax:
const contentAPIRoutes = require('./content-api');
const routes = {
'content-api': {
type: 'content-api',
routes: contentAPIRoutes,
},
};
module.exports = routes;