Closed JKtechhw closed 1 month ago
I tried it a second time on version 5.1.0, but I followed the guide on the Strapi blog instead of the documentation. I didn’t attempt to call the policy as a function, but calling it by name, api::class-page.check-class, worked.
Bug report
Required System information
Describe the bug
Hi, I'm trying to create a custom policy for an API. I edited the core router file for an API named class (which is a collection type created by the Content Type Builder) with the code below. However, when I try to run Strapi again, I get the following error: Error: Error creating endpoint GET /classes: Policy not found.
I attempted to create the policy for the API using the
npm strapi generate
command and in the router I replaced the function with the policy name, but the same issue persists. The only difference is that the policy name appears in the error message.Thanks
Steps to reproduce the behavior
Expected behavior
Working policy
Code snippets
Additional context
Error detail
Error: Error creating endpoint GET /classes: Policy not found. at resolveHandler (/home/user/Documents//{project name}/strapi/node_ modules/@strapi/core/dist/registries/policies.js:37:13) at /home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/registries/policies.js:100:20 at Array.map ()
at Object.resolve (/home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/registries/policies.js:98:35)
at Module.createPolicicesMiddleware (/home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/services/server/policy.js:6:51)
at /home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/services/server/compose-endpoint.js:63:16
at createRoute (/home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/services/server/routing.js:71:5)
at /home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/services/server/routing.js:80:9 at Array.forEach ()
at Object.addRoutes (/home/user/Documents/{project name}/strapi/node_modules/@strapi/core/dist/services/server/routing.js:78:21)