System Information
- Strapi Version: 4.15.5
- Operating System: MacOS Sonoma 14.1.2 (23B92)
- Database: sqlite (local)
- Node Version: v20.9.0
- NPM Version: 10.1.0
- Yarn Version: N/A
I’ve observed that this problem is not new. However, I couldn’t really find a solution. Most other posts are old.
So, this is happening after I tried to transition an app, which was using an old strapi version, 3.6.11, to strapi 4.15.5.
I didn’t really have any custom route that I need to set up, but, in order to learn more about strapi, I was trying to set up one, as explained in this official tutorial.
I did exactly as explained in the tutorial, but I still get this error
{"data":null,"error":{"status":403,"name":"ForbiddenError","message":"Forbidden","details":{}}}%
when executing the following command on the terminal
curl http://localhost:1337/api/consultants/with-meta-date
I created the file custom-routes.js
in src/api/consultant/routes/
with
module.exports = {
routes: [
{
method: "GET",
path: "/consultants/with-meta-date",
handler: "consultant.findCustomRoute",
config: {
auth: false
},
},
],
};
I’ve also enabled this route in the admin page, under Settings > USERS & PERMISSIONS PLUGIN > Roles > Public > Consultant > findCustomRoute
.
I still get the error. Nothing works.
I’ve read that the problem may be the API token or maybe the order the way these routes are executed, but I don’t really know which token people are referring to, because I’m quite new to Strapi, and I also don’t know how I would need to reorder my routes, given that I only have a custom route, in a separate file, custom-routes.js
, and I have the following default routes.js
file
'use strict';
const {createCoreRouter} = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::consultant.consultant');
I can call curl http://localhost:1337/api/consultants
and it works fine.
So, why is this problem happening? I don’t really want guesses. If this is supposed to happen because I’ve not done anything, I’d like to know the official solution (not “try this”). If this is a bug, then can you please point me to the Github issue? If this can be solved, how should I do it?