express - vhost 正在继承其他路由
问题描述
我正在尝试为每个虚拟主机使用一组不同的路由
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))
推荐阅读
- amazon-web-services - AWS ECS 计划任务在创建后未执行
- python - pytides和谐波分析
- python - 如何附加到索引[0] 的字典值?
- python - 如何克服这个问题:C++ 程序中的“致命错误:pyhelper.hpp:没有这样的文件或目录”?
- python - AttributeError:“API”对象没有属性“followers_ids”
- html - 为什么100vh的元素比屏幕大?
- python - 使用 python 将文件名从 file1..file1000 重命名为 file1001...file2000
- for-loop - 使用 for 循环删除最后一个字符
- swiftui - 如何在swiftUI中去另一个视图onclick LazyVGrid GridItem?
- python - 做简单的python递归时出现问题