app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
这个代码将允许任何来源的访问。
"proxy": "https://your-backend-url.com"
然后在前端请求Stripe API时,将请求发送给本地代理而非直接发送给Stripe API。
localhost:3000
完成以上步骤后,应该可以在本地主机上成功运行Stripe Checkout示例。