繁体   English   中英

Meteor.js iron:路由器服务器路由触发器RangeError:超出最大调用堆栈大小

[英]Meteor.js iron:router server route triggers RangeError: Maximum call stack size exceeded

我正在服务器上设置Stripe Webhook路由,并已直接从Iron Router的自述文件中复制了代码,但是当我将测试Webhooks从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将测试webhooks转发到我的本地开发计算机。 除了一次打印以上错误外,我没有任何控制台输出。 我也尝试使用Chrome扩展程序Postman击中端点,并且收到相同的错误。

更新:还尝试了此路由定义,没有任何更改

Router.route('/webhooks/stripe', function () {
    var req = this.request;
    var res = this.response;
    res.end('hello from the server\n');
}, {where: 'server'});

我必须做错了事,但是我找不到适合我的示例。 任何帮助表示赞赏。

好的,所以在发布此内容之前,我花了很多时间研究它,事实证明,我确实只需要更改onBeforeAction调用即可排除服务器路由。

我有

Router.onBeforeAction(requireLogin, {except:["home"]});

我需要将其更改为

Router.onBeforeAction(requireLogin, {except:["home", "webhooks"]});

我的requireLogin方法如下所示:

var requireLogin = function() {

    if (! Meteor.user()) {
        if (Meteor.loggingIn()) {
            this.render(this.loadingTemplate);
        }else{
            Router.go('/');
            this.next();
        }
    } else {
        this.next();
    }
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM