Express 忽略 RegExp 路由,但提供字符串路由?
今天遇到一个很困惑的问题。我一直在 Zappa 中构建一个 CMS 系统,它使用 Express 框架。我正在做自定义路由,所以我有很多“捕获所有”路由。基本上,如果系统未声明某个路由,则会 ping 数据库并查看用户是否在该路由上定义了内容,如果存在则显示它。
直到今天,这一切都运转良好。我不知道我做了什么(我正在做一些完全不同的事情,并做了无数的改变),但突然 RegExp 路由停止工作。完全就好像 Express 完全忽略了它们一样。
以下代码有效:
get '/', ->
render 'some_view'
而以下代码无效:
get /\//, ->
render 'some_view'
这当然只是一个示例。 所有正则表达式路由都被忽略。
我不知所措。我尝试删除我正在工作的dynamicHelpers、我的整个身份验证模块(在今天之前不存在)以及我能想到的所有其他主要内容。除了安装 bcrypt 和 node-validator 之外,我没有对 node.js 执行任何操作。为什么 Express 突然忽略一种类型的路线,而不是另一种类型?
I'm met with a perplexing issue today. I've been building a CMS system in Zappa, which uses the Express framework. I'm doing custom routing, so I have quite a few "Catch all" routes. Basically, if a route isn't claimed by the system, this instead pings the database and sees if the user has defined content at that route, and displays it if it exists.
This was working beautifully until today. I don't know what I did (I was working on something completely different and made about a bazillion changes) but suddenly RegExp routes stopped working. Completely, it's as though Express just ignores them alltogether.
The following code works:
get '/', ->
render 'some_view'
and the following code does not:
get /\//, ->
render 'some_view'
This is just an example of course. All RegExp routes are being ignored.
I'm at a loss. I've tried removing the dynamicHelpers that I was working, on, my entire auth module (which didn't exist before today) and every other major thing I could think of in turn. I haven't done anything to node.js other than install bcrypt and node-validator. Why is Express suddenly ignoring one type of route, but not another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论