Strapi not picking up changes to services.ts or controllers.ts, but sees changes to lifecycles.ts

Hi there, I’m trying to modify the create/update behavior of one of our services (for an Article), but for some reason Strapi is not picking up these changes.

For the simplest example, if I modify the Article’s services.ts file to immediately throw an error, Strapi shows no error in the logs or UI and does not prevent me from creating Articles in the Admin UI. This is the same for the Article service. However, if I create the content-types/article/lifecycles.ts file and modify the beforeCreate there, that does get invoked.

// src/api/article/services/article.ts
import { factories } from '@strapi/strapi'

export default factories.createCoreService('api::article.article', ({ strapi }) => ({
  async create(params) {
    // This never gets called
    throw new Error('should break')

Our configuration is very standard, I must be missing something rather obvious.

This topic has been created from a Discord post (1231006553373413458) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Bump, we’re still facing this issue

Those controllers and services are not used by the admin API, only the content API.

I assume you are testing these changes using the admin? If so you won’t see any difference since the admin API is contained within the content manager package.

There are two entirely different REST apis in a Strapi app:

  • admin API: used by the admin panel and authenticated with the RBAC system
  • content API: the public rest API used by your frontend to talk to Strapi authenticated by users-permissions or API tokens.

The reason lifecycles work is because they wrap the database queries and those controllers and services are the public ones.

The admin API doesn’t have specific routes/controllers/services, there is just single ones that use arguments to know which content-type to execute logic against.