【发布时间】:2016-05-25 17:29:55
【问题描述】:
我们正在开发中使用 browsersync。对于付款确认,付款提供商回传到预定义的 url。
问题是,Browsersync 只显示Cannot POST /payment/success。
所以我正在考虑编写一个中间件,它接受 POST 请求并重定向到与 GET 请求相同的 URL。问题是,我不确定浏览器同步是否可行。当我尝试调用res.redirect('/') 时,它会抛出一个错误:
browserSync.init
server:
baseDir: "...."
index: "/statics/master.html"
middleware: [
modRewrite(['!\\.\\w+$ /statics/master.html [L]']),
(req, res, next) ->
res.redirect('/') # this throws a TypeError: res.redirect is not a function
]
- 为什么没有定义
res.redirect?我以为浏览器同步是基于 express 的?- 如何访问发布请求的正文?
req.body返回undefined
【问题讨论】:
标签: node.js express browser-sync