Skip to main content
Kyle_Joseph
May 2, 2024
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
  • 341 views

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.

1 reply

Kyle_Joseph
May 14, 2024

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.