vhost 正在继承其他路由

vhost is inheriting other routes

我正在尝试为每个虚拟主机使用一组不同的路由

module.exports = function(app) {

    app.use(vhost('www.example.com', exampleRoutes))
    app.use(vhost('*.example.com', subdomainRoutes))

}

我的问题是 www.example 也在使用来自 subdomainRoutes 的路由 我需要以某种方式指定,如果我在 www 下,那么只有 exampleRoutes 应该工作

更新。看起来我可以使用正则表达式。我需要像

这样的东西

不是(www.example.com) 但我对正则表达式很糟糕:(

留在这里以备不时之需。

const regex = new RegExp('^(?!.*www.example.*).*$');
app.use(vhost(regex, subdomainRoutes))