Lamba url + .net core api, how to remove duplicate cors 'Access-Control-Allow-Origin'
From the chrome console. Access to fetch at 'https://lambdaurl' from origin 'https://localhost:5002' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
It looks like both the core web api and lambda are adding the 'Access-Control-Allow-Origin':* header and chrome is not happy. Is there a way to configure lambda url to not duplicate the header.
Can you provide more details around what you were doing?
If you handle CORS in your .NET code, you can deactivate the automatic CORS handling for the Lambda function. This option can be deactivated either using AWS Management Console or via AWS CLI. If you deploy your function using IaC (e.g. CloudFormation or SAM), do not set the corresponding configuration there, that means - do not specify the
Note that automatic CORS handling is deactivated by default.
You could also read this blog post which explains how to configure Lambda URLs.
Alternatively, you can leverage the Lambda function functionality to automatically handle CORS for you. Then, you should remove the CORS configuration from your .NET Web API initialization code (
CORS Access-Control-Allow-Origin not displayed in API Gateway consoleasked a year ago
I am getting CORS errors in S3 console, is this a bug with AWS S3?asked 2 months ago
API Gateway HTTP + Lambda integration not enabling CORSasked 4 months ago
Lamba url + .net core api, how to remove duplicate cors 'Access-Control-Allow-Origin'Accepted Answerasked 3 months ago
Cloudfront distribution returning incorrect CORS headersasked 7 months ago
Bypass CORS policy on S3-hosted site connected to RDS databaseasked 3 months ago
Accessing Pinpoint API from the browserAccepted Answerasked 3 years ago
Problems with CORS when creating Creating API's from CloudFormation / SAMasked 3 years ago
Maximum number of Integrations for this API has been reached?asked 3 years ago
API Gateway CORS error after update aws-cdk update to 1.135.0asked 4 months ago