Skip to content

Commit

Permalink
Merge pull request #7212 from strapi/fix/issue-7196
Browse files Browse the repository at this point in the history
Fix admin routes and user controllers conflicting
  • Loading branch information
alexandrebodin committed Jul 27, 2020
2 parents 9c4728c + 0369d5f commit c4472f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/strapi/lib/middlewares/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = strapi => {
});

_.get(strapi.admin, 'config.routes', []).forEach(route => {
composeEndpoint(route, { router });
composeEndpoint(route, { plugin: 'admin', router });
});

// Mount admin router on Strapi router
Expand Down
7 changes: 5 additions & 2 deletions packages/strapi/lib/middlewares/router/utils/routerChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ module.exports = strapi =>
let controller;

if (plugin) {
controller = strapi.plugins[plugin].controllers[controllerKey];
controller =
plugin === 'admin'
? strapi.admin.controllers[controllerKey]
: strapi.plugins[plugin].controllers[controllerKey];
} else {
controller = strapi.controllers[controllerKey] || strapi.admin.controllers[controllerKey];
controller = strapi.controllers[controllerKey];
}

if (!_.isFunction(controller[actionName])) {
Expand Down

0 comments on commit c4472f6

Please sign in to comment.