vhost 正在继承其他路由
Posted
技术标签:
【中文标题】vhost 正在继承其他路由【英文标题】:vhost is inheriting other routes 【发布时间】:2020-01-09 18:59:17 【问题描述】:我正在尝试为每个虚拟主机使用一组不同的路由
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)但我对正则表达式很糟糕:(
【问题讨论】:
【参考方案1】:把这个放在这里以防有人需要。
const regex = new RegExp('^(?!.*www.example.*).*$');
app.use(vhost(regex, subdomainRoutes))
【讨论】:
以上是关于vhost 正在继承其他路由的主要内容,如果未能解决你的问题,请参考以下文章