ContentBox Admin Module Routing

I have a question about ContentBox Admin Module routing.

Module Location:
/modules_app/contentbox-custom/_modules/myModuleName

I can access my module from /cbadmin/module/myModuleName. I don’t want or need this module to be accessible from /myModuleName.

What is the best method to ensure routes from the root of the site are not registered?

@MikeR All modules have an entrypoint assigned by Coldbox when they are registered. If you don’t want those routes to be accessbile, then you can just use the module’s router to relocate any requests to that route back to the root of the site:

route(
    pattern=":handler?/:action?",
    target=function( event, rc, prc ){
        relocate( '/' )
    }
);

Thanks for the help @jclausen, very much appreciated.

To clarify I do need routes like:

/cbadmin/module/myModuleName/myHander/myAction
/* prc gets decorated by cbadmin */

Not:

/myModuleName/myHander/myAction
/* routes throw errors since the prc is not decorated by cbadmin */

(I don’t need these routes anyway)

When I add this to my config/router.cfc file:

route(
    pattern=":handler?/:action?",
    target=function( event, rc, prc ){
        relocate( '/' );
    }
);

all routes, even

/cbAdmin/module/myModuleName/myHandler/myAction 

redirect back to the home page. I must be missing something that I am sure is obvious. :man_shrugging:

If you are using the convention routing for those admin routes then you will have to have a simple route for “/“ which points to that function. Otherwise declare explicit routes for those admin routes you want.

Thanks again for all your help @jclausen, very much appreciated.

I still couldn’t quite get what I needed with routing alone. I am sure I am missing something, however, with a combination of routes, preHander, and an onInvalidEvent interceptor my module now either does not have the routes even exist or redirect the event and display the ContentBox default notfound “Ooops” page.

I wanted to make sure I was catching and handling the possible scenarios for routes before I publish on ForgeBox. If you have a minute and want to take a quick look, any feedback is very much appreciated.