1

几个明显的项目:

我正在使用流星路由器。我已经通过 Meteorite 安装了电子邮件包。


这是我正在尝试做的事情:

  1. 当用户注册时,我设置了 Stripe 以在他们的末端创建一个客户(工作)。
  2. 创建该客户后,Stripe 会创建一个事件并通过 webhook,通过将发布数据发送到http://myapp.meteor.com/stripe与我共享该事件的数据。
  3. 收到发布数据后,我的应用程序会提取客户的电子邮件地址并触发 Meteor 方法,该方法会向该地址发送电子邮件。

我遇到的问题是,在第一次尝试时(即原始事件发生时),我在 Stripe 中收到 503 错误。但是,如果我再次从 Stripe 内部发出请求,Meteor 会接受它并发送电子邮件就好了。为什么它会第二次(以及之后的多次)起作用,但不是第一次。这是我当前的代码:

if(Meteor.isServer) {

  Meteor.startup(function () {
    process.env.MAIL_URL = /* OBSCURED */;
  });

  Meteor.methods({

    sendEmail: function(address, subject, text) {

      Email.send({
        to: address,
        from: "test@myapp.com", /* OBSCURED ADDRESS */
        subject: subject,
        text: text
      });

    }

  });

  Meteor.Router.add(

    '/stripe', 'POST', function() {  

      // Grab Post Data
      post = this.request.body;

      // Test Type of Post
               type = post.type
      customerEmail = post.data.object.email;        

      var email = [customerEmail, "Welcome to My App!", type];

      Meteor.apply("sendEmail", email);

      return [200, "Success"];

  });

}

我注意到,当发送 Stripe 请求时,我在控制台中看到以下内容:

XMLHttpRequest cannot load https://ddp--0675-[myapp].meteor.com/sockjs/903/1szdgor_/xhr. Origin http://[myapp].meteor.com is not allowed by Access-Control-Allow-Origin.

我在这里想念什么?

4

0 回答 0