Skip to content

Commit 02bc094

Browse files
committed
fix request's baseUrl in autoRouter
1 parent dd1a6ac commit 02bc094

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

plugins/dispatcher/dispatcher.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module.exports = function (options) {
5757
debuglog('actually get router [%s]', router.__name__);
5858
if (router.__name__ === routerName && req.params.router) {
5959
req.url = shiftUrl(req.url);
60+
req.baseUrl = (req.baseUrl || '') + '/' + routerName;
6061
debuglog('router is matched, remove router from url [%s]', req.url);
6162
}
6263
debuglog('[%s] lookup for user defined router', req.url);
@@ -88,6 +89,7 @@ module.exports = function (options) {
8889
debuglog('actually get action [%s]', action.__name__);
8990
if (action.__name__ === actionName && req.params.action) {
9091
req.url = shiftUrl(req.url);
92+
req.baseUrl = (req.baseUrl || '') + '/' + actionName;
9193
debuglog('action is matched, remove action from url [%s]', req.url);
9294
}
9395
action(req, res, next);

0 commit comments

Comments
 (0)