【问题标题】:how fix cors error on react app and coinbase connect api如何修复 react app 和 coinbase connect api 上的 cors 错误
【发布时间】:2022-01-20 11:26:09
【问题描述】:

我无法获取 coinbase 连接 OAuth2 api 的授权 URL。

fetch("https://www.coinbase.com/oauth/authorize?response_type=code&client_id=cc460ce71913c49e4face4ac0e072c38564fabea867ebcd7ab9905970d8f3021&redirect_uri=http://localhost:3000/callback&state=SECURE_RANDOM&scope=wallet:accounts:read")
      .then(res => res.json())
      .then(
        (result) => {
          console.log(result)
        },
        (error) => {
          console.log(error)
        }
      )

给我这个错误

enter image description here

【问题讨论】:

标签: reactjs api http oauth-2.0 coinbase-api


【解决方案1】:

你可以像这样禁用cors:

fetch('https://www.coinbase.com/oauth/authorize?response_type=code&client_id=cc460ce71913c49e4face4ac0e072c38564fabea867ebcd7ab9905970d8f3021&redirect_uri=http://localhost:3000/callback&state=SECURE_RANDOM&scope=wallet:accounts:read', {
mode: 'no-cors',
method:'GET'
}).then(res => res.json())
  .then(
    (result) => {
      console.log(result)
    },
    (error) => {
      console.log(error)
    }
  )

【讨论】:

    猜你喜欢
    • 2020-02-28
    • 2021-11-30
    • 2020-01-15
    • 1970-01-01
    • 2023-03-18
    • 2019-11-11
    • 1970-01-01
    • 1970-01-01
    • 2022-08-14
    相关资源
    最近更新 更多