authentication - Custom plugin routes are not accessible using API tokens - Stack Overflow

I am using strapi V4. I have created the custom plugin where I have defined some routes in the srcplug

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.

Share Improve this question asked Mar 24 at 7:53 Drashti KheniDrashti Kheni 1,13910 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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;

Reference:
https://github/strapi-community/plugin-healthcheck/blob/b86874915cf2087dd84f4fa922476f7071791e6d/server/src/routes/index.js#L4

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744255508a4565380.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信