From 02bc0945acf9b7b3359f49807ac2d181f332bcf0 Mon Sep 17 00:00:00 2001 From: ssddi456 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 6303610..d3cb10e 100644 --- a/plugins/dispatcher/dispatcher.js +++ b/plugins/dispatcher/dispatcher.js @@ -57,6 +57,7 @@ module.exports = function (options) { debuglog('actually get router [%s]', router.__name__); if (router.__name__ === routerName && req.params.router) { 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); @@ -88,6 +89,7 @@ module.exports = function (options) { debuglog('actually get action [%s]', action.__name__); if (action.__name__ === actionName && req.params.action) { 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);