2

Generating the request to list the vpc details with IAM token which is kept in authorization header - The request has been generated from React App -

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

Configuration

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

The request was failed during the pre-flight request, it seems that the browser request headers are asking the server for permissions to make the actual request.

Can you suggest to overcome the problem.

Ishmeet
  • 1,540
  • 4
  • 17
  • 34
DEngineer
  • 41
  • 3

1 Answers1

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"
Powell Quiring
  • 2,349
  • 2
  • 11
  • 9
  • Yes, i have used the correct URL which is mentioned in the documentation as "https://us-south.iaas.cloud.ibm.com". However, i was requesting it through browser with my own react application, browser itself sends pre-flight request to server to ensure CORS. Hence, the next subsequent request was failing from browser. I was able to execute it well with curl. The problem is generated when it is implemented through UI app like react etc from browser. hope it clarifies. thanks – DEngineer Aug 07 '19 at 05:24