Skip to main content
Question

Documentation states you can access APIs with wildcard allow origin but it's not the case at least with AWS API Gateway

  • May 2, 2024
  • 1 reply
  • 264 views

Kyle_Joseph

I have Lambda which uses API Gateway’s http-api, I have configured CORS as below…

httpApi:
    cors:
      allowedOrigins: "*"
      allowedMethods: "*"
      allowedHeaders: "*"
      allowCredentials: false

I have set my response headers…

return {
        statusCode: 201,
        body: JSON.stringify({
            publicKey: 'publicKey',
            privateKey: 'privateKey',
        }),
        headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*',
        },
    };

and yet i still get CORS errors when making the request from the Figma plugin.

The request works if set Origin: null within Postman, so to me it seems that the only solution here is to use a Proxy which I am not keen to do.

Is this a specific issue with API Gateway?

This topic has been closed for replies.

Kyle_Joseph

I managed to solve this issue by creating a proxy that uses API Gateway v1 Rest API that forwards all requests to API Gateway v2 HTTP API, the latter accepts wildcard origins but does not accept an origin of null, which the former does.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings