响应中的条带错误“ Access-Control-Allow-Origin”标头不得为通配符“ *”

时间:2018-09-04 18:15:29

标签: angular cors stripe-payments

我当前正在使用localhost 4200(http://localhost:4200/reserve),尝试连接Stripe API时遇到问题。页面加载后,我在整个控制台上都收到此错误:

  

无法加载https://m.stripe.com/4:当请求的凭据模式为“ include”时,响应中“ Access-Control-Allow-Origin”标头的值不能为通配符“ *”。因此,不允许访问来源“ https://m.stripe.network”。 XMLHttpRequest发起的请求的凭据模式由withCredentials属性控制。       未捕获(承诺)未定义

关于此错误,我已经看到过类似的帖子,没有任何方法可以解决此问题,并且我已经停留了一段时间。我真的只是想用Angular 5建立Stripe Elements付款表单。我还没有迷上后端的任何东西。我确实启用了Chrome CORS插件,这使我目前可以加载页面。

在我的index.html中,我有:

<script src="https://js.stripe.com/v3/"></script>

然后我有一个可重复使用的付款服务,该服务将传递给我的带有Stripe元素的html页面:

import { Injectable } from "@angular/core";
declare var Stripe: any;

@Injectable()
export class PaymentService {
     constructor() { }

     stripe = Stripe('test_key');
}

此行引发了我上面提到的控制台错误:

stripe = Stripe('test_key');

非常感谢您的帮助。预先感谢。

0 个答案:

没有答案