Skip to content

Commit 407fc86

Browse files
committed
fix request's baseUrl in autoRouter
1 parent 9d53e97 commit 407fc86

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
@@ -62,6 +62,7 @@ module.exports = function (options) {
6262
debuglog('actually get router [%s]', router.__name__);
6363
if (router.__name__ === routerName && req.params.router && shiftRouterNameFromUrl) {
6464
req.url = shiftUrl(req.url);
65+
req.baseUrl = (req.baseUrl || '') + '/' + routerName;
6566
debuglog('router is matched, remove router from url [%s]', req.url);
6667
}
6768
debuglog('[%s] lookup for user defined router', req.url);
@@ -93,6 +94,7 @@ module.exports = function (options) {
9394
debuglog('actually get action [%s]', action.__name__);
9495
if (action.__name__ === actionName && req.params.action && shiftRouterNameFromUrl) {
9596
req.url = shiftUrl(req.url);
97+
req.baseUrl = (req.baseUrl || '') + '/' + actionName;
9698
debuglog('action is matched, remove action from url [%s]', req.url);
9799
}
98100
action(req, res, next);

0 commit comments

Comments
 (0)