我的coinbase付款按钮将不会显示。我从coinbase收到此错误消息:

拒绝在框架中显示“https://coinbase.com/transactions”,因为它将“X-Frame-Options”设置为“SAMORIGIN”

他们的客户服务糟透了,我已经等了2天才能解决此问题。

我在htaccess中尝试过

Header set Access-Control-Allow-Origin "%{HTTP_ORIGIN}e" env=HTTP_ORIGIN

<ifModule mod_headers.c>
Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Methods  "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "X-    Requested-With"
</ifModule>

这些都不起作用...

我该如何解决?

iframe就是他们的按钮的工作方式。如果我使用他们的演示按钮,效果很好。当我将演示按钮上的数据代码更改为我的数据代码时,它将引发该错误。

最佳答案

我在这里发布,因为。

我正在使用此react组件:https://github.com/coinbase/react-coinbase-commerce

我的费用看起来像:

const myNewChargeObj = {
  addresses:
   { bitcoincash: 'qpkwp5s5tr3thjxlejq4qfvkclavx7ur2cce4la6m6',
     bitcoin: '16FZj5WK6Dj7i4mgnaryLnGfy5XRr56fug',
     ethereum: '0xeb7638d57fadb724e97fd4f4b80ed0fb24b8e9d0',
     litecoin: 'Lh8AtZD8Zzy32gZvZAGyBtnBvFCbQ12hf8' },
  code: '9D8FQUP7',
  created_at: '2019-01-10T08:18:53Z',
  description: 'test-desc',
  expires_at: '2019-01-10T09:18:53Z',
  hosted_url: 'https://commerce.coinbase.com/charges/9C7ETZP6',
  id: '27e32b69-563a-40f1-b1c8-ad947dab190c',
  metadata: {},
  name: 'test-purchas-name',
  payments: [],
  pricing:
   { local: { amount: '1337.00', currency: 'USD' },
     ethereum: { amount: '9.820773000', currency: 'ETH' },
     bitcoin: { amount: '0.35138115', currency: 'BTC' },
     bitcoincash: { amount: '9.38838565', currency: 'BCH' },
     litecoin: { amount: '37.66727708', currency: 'LTC' } },
  pricing_type: 'fixed_price',
  resource: 'charge',
  timeline: [ { status: 'NEW', time: '2019-01-10T08:18:53Z' } ]
}

阅读文档使我觉得我应该实例化我的React组件,例如:
...
<CoinbaseCommerceButton checkoutId={'27e32b69-563a-40f1-b1c8-ad947dab190c'}/>
...

这导致客户端遇到OP提到的错误:
Refused to display 'https://commerce.coinbase.com/embed/charges/27e32b69-563a-40f1-b1c8-ad947dab190c?origin=http%3A%2F%2Flocalhost%3A8080&version=1.3.1&buttonId=9dc5056f-6980-4e66-bd7a-920e9aa3c469&cacheDisabled=undefined' in a frame because it set 'X-Frame-Options' to 'deny'

原来,我需要像这样实例化组件:

...
<CoinbaseCommerceButton checkoutId={'9D8FQUP7'}/>
...
然后它起作用了!

快乐黑客。

关于javascript - Coinbase Sameorigin,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20305170/

10-09 22:23