DEngineer
DEngineer

Reputation: 41

Request rejected with Options when fetching the VPCs with Authorization header

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.

Upvotes: 2

Views: 55

Answers (1)

Powell Quiring
Powell Quiring

Reputation: 2464

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"

Upvotes: 0

Related Questions