javascript - Meteor/Stripe: Receiving XMLHttpRequest cannot load error when attempting to post data to server side route in Meteor -
a few obvious items:
i'm using meteor router. i've installed email package via meteorite.
here's i'm attempting do:
- when user signs up, have stripe setup create customer on end (working).
- when customer created, stripe creates event , via webhooks, shares data event me sending post data http://myapp.meteor.com/stripe.
- when post data received, application extracts email address customer , triggers meteor method sends email address.
the problem i'm having on first attempt (i.e. when original event occurs), receive 503 error in stripe. however, if fire request again within stripe, meteor accepts , sends email fine. why work second time (and subsequent times after that), not first. here current code:
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 app!", type]; meteor.apply("sendemail", email); return [200, "success"]; }); }
what have noticed when stripe request sent, see following in console:
xmlhttprequest cannot load https://ddp--0675-[myapp].meteor.com/sockjs/903/1szdgor_/xhr. origin http://[myapp].meteor.com not allowed access-control-allow-origin.
what missing here?
Comments
Post a Comment