I want to hide a specific collection-type from content-manager

System Information
  • Strapi Version: 4.14.0
  • Operating System: macOS Sonoma 14.1.1
  • Database: Postgres 16
  • Node Version: 18.20.3
  • NPM Version: 10.7.0
  • Yarn Version:

To hide a specific collection-type from strapi admin’s content-manager, simply make the following statement in schema.json.

  "pluginOptions": {
    "content-manager": {
      "visible": false
    }
  },

However, if this method is used, the API will not be available.
I would like to know if there is a way to hide it for all accounts in the admin panel, but allow it to operate from the API without any problems.

That should still allow you to access it from the api.

I did the same in the following plugin todo-strapi4-plugin/server/content-types/todo/schema.json at 3551a8239a0c568fa1222cb0ce333afb80cda3a5 · PaulBratslavsky/todo-strapi4-plugin · GitHub

  "pluginOptions": {
    "content-manager": { 
      "visible": false
    },

    "content-type-builder": {
      "visible": false
    }
  },

This allowed me to hide the collection from the admin panel, but I still had access to it via API.

I wonder if there is something else that is happening.

Did you test trying to get the content from before the change, was it working?

Thanks for the reply!
This happened to me with the following code.

  • axiosInstance.js
import { auth } from '@strapi/helper-plugin';
import axios from 'axios';

export const instance = axios.create({
  baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
  headers: {
    Authorization: `Bearer ${auth.getToken()}`,
    'Content-Type': 'application/json'
  }
});
  • src/pulugins/{plugin-name}/admin/src/components/{page-name}/index.jsx
  React.useEffect(() => {
    const getProducts = async () => {
      const r = await axiosInstance.get(
        `/content-manager/collection-types/api::product.product`
      );
      console.log(r);
    };
    getProducts();
  }, []);

If you try to call the API in your own plugin like this, you will get a 403 error.

スクリーンショット 2024-09-05 11.08.18

However, it can be made accessible by deleting the "visible": false statement.

Is there a problem with the way the API is called?
I would like to know the proper way to call it.

Sorry, solved.

Your todo plugin was very helpful.

I defined the service on the server side like this and called it using the entityService, and the API was called without any problems.

Thank you very much.