【发布时间】:2015-10-19 13:49:34
【问题描述】:
我正在我的服务器上设置 Stripe webhook 路由,并直接从 Iron 路由器的自述文件中复制了代码,但是当我将测试 webhook 从 stripe 发送到我的服务器时,我收到 RangeError。
我的路线定义如下:
Router.route('/webhooks/stripe', { where: 'server' })
.get(function () {
// GET /webhooks/stripe
console.log("Get request from stripe")
})
.post(function () {
// POST /webhooks/stripe
console.log("Received POST Webhook from Stripe");
console.log(this);
this.response.end('webhook ended');
})
.put(function () {
// PUT /webhooks/stripe
console.log("Put request from stripe")
})
我也尝试过这样定义路线:
Router.map(function(){
this.route("webhooks", {layoutTemplate:null, path:'/webhooks/stripe', where:"server"}).post(function () {
// POST /webhooks/stripe
console.log("Received POST Webhook from Stripe");
console.log(this);
// // NodeJS response object
// var response = this.response;
this.response.end('webhook ended');
})
})
我正在使用 ultrahook 将测试 webhook 转发到我的本地开发机器。除了一次打印上述错误外,我没有得到任何控制台输出。 我还尝试使用 Chrome 扩展 Postman 访问端点,但收到相同的错误。
更新: 也尝试了这个路由定义没有改变
Router.route('/webhooks/stripe', function () {
var req = this.request;
var res = this.response;
res.end('hello from the server\n');
}, {where: 'server'});
我必须做错事,但我无法找到适合我的示例。任何帮助表示赞赏。
【问题讨论】:
-
Maximum call stack size exceeded几乎总是来自失控的递归调用。也请注意! -
是的,我知道这是正常原因,但在这种情况下,请求在引发该错误之前似乎甚至没有到达我的路线。感谢您的评论。
标签: javascript meteor stripe-payments iron-router webhooks