-1

I am new to both Stripe API and CORS concept. I basically send a POST request from Angular to my Node js server. The client origin is different to server destination so I have implemented CORS at server side. Using a network tab on Chrome, I can see a preflight request going OK then the actual request failing. I do not actually know what went wrong with it. Could anybody give me some advice or explain what I am missing here? Thank you in advance

Preflight Request (OPTIONS) enter image description here

Actual Request (POST) enter image description here

Client Side (Angular) enter image description here

Server Side (Node JS) - cont. enter image description here

Server Side (Node JS)

enter image description here

david park
  • 139
  • 2
  • 11
  • you are sending a dom element as data. That is very wrong. Problem has nothing to do with CORS but handling of the actual post – charlietfl Oct 09 '16 at 14:50
  • This kind of error indicates that your server post handler is crashing out. Start by just console logging the request body inside the post handler and go from there. @charlietfl suggestion may be the culprit - your server might be choking on this data – cyberwombat Oct 09 '16 at 20:18
  • You're getting a 503 error, so this is a server-side error (which may be due to the contents of your request), and has nothing to do with CORS (if it were, it wouldn't even reach the server). Doesn't seem to have much to do with Stripe either. – jcaron Oct 09 '16 at 22:31

1 Answers1

-2
  • How do you set up the domain?

  • Did you use another HTTP server as a proxy?

  • Please check if node is running, and if yes check your HTTP server is too.

  • Maybe your node crashed or is just not running.

Refer this answer

Something else you could do is try and hit the URL directly using localhost:XXXX/path using CURL or Postman and see if the server is responding.

Also, I see that your content-type is HTML. Is that correct or should it be application/json? I say this because you said the pre-flight went in fine. This is a known issue with CORS requests

Community
  • 1
  • 1
nikjohn
  • 20,026
  • 14
  • 50
  • 86