https://pulumi.com logo
Title
f

flat-car-33421

12/14/2020, 6:07 PM
although i am returning, *headers: { “Access-Control-Allow-Origin”: “*” }*, from my lambda function and also got following configuration for API Gateway endpoint: // add vote api const songsAddApiResource = new aws.apigateway.Resource(preName(‘voteresource’), { restApi: songsApiRest.id, parentId: songsApiRest.rootResourceId, pathPart: ‘vote’ }) const authApi = new aws.apigateway.Authorizer(preName(‘authorizer’), { restApi: songsApiRest.id, authorizerUri: authFunction.invokeArn }) const songsAddApiMethod = new aws.apigateway.Method(preName(‘votemethod’), { restApi: songsApiRest.id, resourceId: songsAddApiResource.id, authorization: ‘CUSTOM’, authorizerId: authApi.id, httpMethod: ‘POST’ }) const songsAddApiIntegration = new aws.apigateway.Integration(preName(‘voteintegration-post’), { restApi: songsApiRest.id, resourceId: songsAddApiResource.id, httpMethod: songsAddApiMethod.httpMethod, integrationHttpMethod: ‘POST’, type: ‘AWS_PROXY’, uri: recordVotesFunction.invokeArn }) i am still getting following CORS error while accessing post endpoint from javascript: has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
1
f

faint-table-42725

12/15/2020, 12:09 AM
The pre-flight request makes a request via the
OPTIONS
method, so you’ll need to define an integration to return your CORS headers against that
f

flat-car-33421

12/15/2020, 1:55 PM
do you have any code sample using aws.apigateway lib?
f

faint-table-42725

12/15/2020, 5:53 PM
provides a couple examples (one via lambda and another via the mock integrations)
f

flat-car-33421

12/15/2020, 6:33 PM
thanks