2

使用保存在授权标头中的 IAM 令牌生成请求以列出 vpc 详细信息 - 请求已从 React App 生成 -

https://urls.cloud.ibm.com/v1/vpcs?version=2019-08-06&generation=1

配置

config = {
        headers: {
        "Authorization": "Bearer lmtmlmlm",
        "Access-Control-Allow-Origin": "*"
      }
    }

请求在飞行前请求期间失败,似乎浏览器请求标头正在向服务器请求权限以发出实际请求。

你能建议克服这个问题吗?

4

1 回答 1

0

The instructions here worked well for me: https://cloud.ibm.com/docs/vpc-on-classic?topic=vpc-on-classic-creating-a-vpc-using-the-rest-apis

I noticed you used the url: https://urls.cloud.ibm.com while these docs suggested https://us-south.iaas.cloud.ibm.com

rias_endpoint="https://us-south.iaas.cloud.ibm.com"
iam_token='Bearer zzzrandomstuff...eyJraWQiOiIyMDE5MDUxMyIsImFsZyI6IlJTMjU2In'
version="2019-05-31"
curl -X GET "$rias_endpoint/v1/vpcs?version=$version&generation=1" -H "Authorization: $iam_token"
于 2019-08-06T20:20:34.203 回答