【发布时间】:2020-03-12 22:37:26
【问题描述】:
我在我的路由器中使用这个正则表达式
/^\/(?!api|mailAction(\/|\?))(.*)$/
因为路由器只允许api/或api?或mailAction/或mailAction?
现在路由器设置如下 -
app.get(/^\/(?!api|mailAction(\/|\?))(.*)$/, (req, res) => {
console.log('not matched')
if (req.isMobile) {
return res.sendFile(path.join(FE.APP_PATH, "dist", "mob", this.clientName, "index.html"));
} else {
return res.sendFile(path.join(FE.APP_PATH, "dist", "web", this.clientName, "index.html"));
}
});
当 URL 为 http://fe.localhost:4000/mailAction?t=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXfVCJ9.eyJ0b2tlbklkIjo2MywiaWF0IjoxNTg0MDE4NjE2LCJleHAiOjE1ODQwNTQ2MTZ9.mCKwrMN2ppLlEMSp4U1_AwmNLDOjplOmnYTaFADf6FQ&a=ACT00000205 时,它仍会以中间件的形式提供 index.html 文件。我无法理解为什么。请帮忙。
提前致谢。
【问题讨论】:
标签: javascript node.js regex express