2

我正在开发一个 Ruby on Rails 应用程序,我计划在其中集成 Stripe 支付。我正在使用stripe宝石。我打算使用 Elements,如此处所述

我包括这样的 Stripe js:

= javascript_include_tag 'https://js.stripe.com/v3/'

在我的charges.coffee文件中,我有这个:

$(document).on 'turbolinks:load', ->
  stripe = Stripe("<%= Rails.application.secrets['STRIPE_PUBLISHABLE_KEY'] %>")
  elements = stripe.elements()

当我加载应用程序时,我目前在 Safari 中收到以下错误:

Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.

关于我可以做些什么来解决这个问题的任何想法?

4

1 回答 1

0

我今天通过将 secure_headers gem 从 v3 升级到最新的 v5 解决了这个问题,我不合逻辑的 CSP 错误消失了。

于 2017-11-30T02:18:24.377 回答