Strapi menus: relational type giving back 405 error

System Information
  • Strapi Version: 4.2.0
  • Operating System: Windows
  • Database: PostgreSQL

I want a webmaster to be able to create pages and manage a menu. I installed the Strapi menus plugin. This lets you create & edit a menu structure in a visual way, which is perfect. The downside of this plugin is that you need to type the URL for the menu item. Instead, I want the webmaster to be able to select a page. So I thought; let’s extend the Strapi menus with a relational type that can select my Page collection type. (Is this the way to go, or is there maybe a simpler solution?)

I made a collection type: Page, which is reachable in the backend via:

http://localhost:1337/admin/content-manager/collectionType/api::page.page

I copied the code from here: Menus | Strapi Market, and edited the target such that is matches my target:

const customAttrs = {
    example_relation_one: {
        type: 'relation',
        relation: 'oneToOne',
        target: 'api::page.page',
    },
    example_relation_many: {
        type: 'relation',
        relation: 'oneToMany',
        target: 'api::page.page',
    },
};

The Strapi backend starts and shows the field as expected. However, when I try to select a relation, it gives back a 405 error, which I don’t understand. Why is it trying to post something here in the first place?

What am I doing wrong? Any help would be appreciated!

If you want me to share more details, please let me know.

Thank you,
Melvin

Of course, after making such a topic, a wild idea enters the mind:

I don’t need the plug-in for this, I can use Strapi’s components and single types to build my own nested menu. I only need 1 level of nesting, which keeps things simple.

Maybe this helps someone looking for an answer:

I created a MenuItem component and a SubMenuItem component. Then, I created a single type “Main menu”, which holds the repeatable component of MenuItem:

The UI might not be as fancy as with the Menus plugin, but it does the job