Why am I getting 403 when trying to access a custom route?

[Update] Upon further research I was pointed to this documentation article.

Explainer video here

Custom routes are loaded in “alphabetical order”

So you need to make sure that the custom route file that you added is loaded first.

You can accomplish this my renaming your rotes.

For your custom routes you can call your file 1-custom-routes.js and then rename the consultant.js to 2-custom-routes.js.

Now everything should work as expected, we can check by running the yarn strapi routes:list command to see all the routes.

We now see that our custom route is loaded first.

[Original Message] I left this for context.

Thanks for the feedback. I tested your example and you are correct. This should not be the expected behavior.

I will create a bug for it [update - not a bug]. So the reason why it is failing is due to the ordering of routes.

To fix this for the time being you can just define you route like so.

module.exports = {
  routes: [
    {
      method: "GET",
      path: "/consultants/custom/with-meta-date",
      handler: "consultant.findCustomRoute",
    },
  ],
};

I will create a bug report for this.

1 Like