From 407fc86a3f60a555a2c937d97faea20bc3b2544f Mon Sep 17 00:00:00 2001 From: ssddi456 <torrent88410@gmail.com> Date: Fri, 28 Apr 2017 12:35:08 +0800 Subject: [PATCH] fix request's baseUrl in autoRouter --- plugins/dispatcher/dispatcher.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/dispatcher/dispatcher.js b/plugins/dispatcher/dispatcher.js index 24abbca..75ecc79 100644 --- a/plugins/dispatcher/dispatcher.js +++ b/plugins/dispatcher/dispatcher.js @@ -62,6 +62,7 @@ module.exports = function (options) { debuglog('actually get router [%s]', router.__name__); if (router.__name__ === routerName && req.params.router && shiftRouterNameFromUrl) { req.url = shiftUrl(req.url); + req.baseUrl = (req.baseUrl || '') + '/' + routerName; debuglog('router is matched, remove router from url [%s]', req.url); } debuglog('[%s] lookup for user defined router', req.url); @@ -93,6 +94,7 @@ module.exports = function (options) { debuglog('actually get action [%s]', action.__name__); if (action.__name__ === actionName && req.params.action && shiftRouterNameFromUrl) { req.url = shiftUrl(req.url); + req.baseUrl = (req.baseUrl || '') + '/' + actionName; debuglog('action is matched, remove action from url [%s]', req.url); } action(req, res, next);