although i am returning, *headers: { “Access-Contr...
# aws
f
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
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
do you have any code sample using aws.apigateway lib?
f
provides a couple examples (one via lambda and another via the mock integrations)
f
thanks