简体   繁体   English

使用Angular的Stripe API的CORS问题

[英]CORS Issue with Stripe API using Angular

I am new to both Stripe API and CORS concept. 我对Stripe API和CORS概念都是陌生的。 I basically send a POST request from Angular to my Node js server. 我基本上是从Angular向我的Node js服务器发送一个POST请求。 The client origin is different to server destination so I have implemented CORS at server side. 客户端起源与服务器目标不同,因此我在服务器端实现了CORS。 Using a network tab on Chrome, I can see a preflight request going OK then the actual request failing. 使用Chrome上的网络标签,我可以看到预检请求正常,然后实际请求失败。 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) 飞行前请求(选项) 在此处输入图片说明

Actual Request (POST) 实际要求(POST) 在此处输入图片说明

Client Side (Angular) 客户端(角度) 在此处输入图片说明

Server Side (Node JS) - cont. 服务器端(节点JS)-续 在此处输入图片说明

Server Side (Node JS) 服务器端(Node JS)

在此处输入图片说明

  • How do you set up the domain? 您如何设置域?

  • Did you use another HTTP server as a proxy? 您是否使用其他HTTP服务器作为代理?

  • Please check if node is running, and if yes check your HTTP server is too. 请检查节点是否正在运行,如果是,请检查您的HTTP服务器是否也在运行。

  • 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. 您可以做的其他事情是尝试使用CURL或Postman使用localhost:XXXX/path直接访问URL,然后查看服务器是否响应。

Also, I see that your content-type is HTML. 另外,我看到您的content-type是HTML。 Is that correct or should it be application/json ? 那是正确的还是应该是application/json I say this because you said the pre-flight went in fine. 我说这是因为您说飞行前进行得很好。 This is a known issue with CORS requests 这是CORS请求的已知问题

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

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