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.
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.
1 Answer
Reset to default 0There 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;
Reference:
https://github/strapi-community/plugin-healthcheck/blob/b86874915cf2087dd84f4fa922476f7071791e6d/server/src/routes/index.js#L4
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744255508a4565380.html
评论列表(0条)