Hopefully this will save others from this newbie error when registering a view that is not for a content type (content type views are managed using config.views.contentTypesViews... in your src/config.js).
To ensure your custom routes are given priority over default routes, make sure that your route is registered BEFORE the addonRoutes and defaultRoutes.
Here's a snippet from a project I'm working on to register a new route for a component in Volto.
This code is added to the src/routes.js
file of my Volto project, my route is /author/:author_id
.
{
path: '/',
component: App, // Change this if you want a different component
routes: [
// Add your routes here
{
path: '/author/:author_id',
component: AuthorView,
exact: true,
},
...(config.addonRoutes || []),
...defaultRoutes,
],
},
];
When I placed it AFTER the defaultRoutes, one of Volto's default routes got priority over mine specifically this one:
{
path: '/**',
component: View,
},
Once I relocated it to be BEFORE, my route started to resolve as expected.
Hope it helps someone (or my future self ).