I just started using Strapi, so this is probably a silly question. But I was following a course and at one point I had a create a custom route in strapi. The course is using strapi v3 but I am using strapi v4. So I created a custom route following the docs: https://docs.strapi.io/developer-docs/latest/development/backend-customization/routes.html#creating-custom-routers
My route works perfectly fine when I set the path to "/me" but I get a 404 error when the path is set to "/events/me". Although this is a minor inconvenience, I would like to know if there is a way to set the path to "events/me".
Here is my folder structure and code:
api/
├─ event/
│ ├─ content-types/
│ │ ├─ schema.json
│ ├─ controllers/
│ │ ├─ event.js
│ ├─ routes/
│ │ ├─ event.js
│ │ ├─ me.js
│ ├─ services/
│ │ ├─ event.js
With the endpoint '/api/me':
api/event/routes/me.js
"use-strict";
module.exports = {
routes: [
{
method: "GET",
path: "/me",
handler: "event.me",
},
],
};
With the endpoint '/api/events/me':
api/event/routes/me.js
"use-strict";
module.exports = {
routes: [
{
method: "GET",
path: "/events/me",
handler: "event.me",
},
],
};
Edit:
I think strapi confuses my custom endpoint 'events/me' with the core route endpoint for findOne which is 'events/:id'. So the '/me' part of my endpoint is probably considered the ':id', and as there is no id of 'me', I get a 404 error. Would there be a way to prioritize my custom route over the core route for findOne?