ASP.NET Web API on AWS Lambda CORS

0

Hello everyone,

I hope I'm posting this in the right place, this is my first post here.

I'm rather new to the AWS scene and so I apologize if this has been asked and answered before. Believe me I have looked everywhere for the past 3 full days before I allowed myself to ask.

I've made a web API with C# and deployed it to AWS Lambda using the AWS Toolkit for VS 2019. This all goes well, and the API does in fact work, however.. once I try integrating API from my website, I keep getting a CORS error. I've only ever made backends with nodejs in the past, so I have no clue how to enable CORS on my web API.

I've seen a few examples to go on the AWS website and use the website graphical interface to enable CORS, but I cannot seem to find where my web API is deployed to, in order to even access its settings.

I will really appreciate any form of help!

Thank you in advance, Matt

Matt
asked 2 years ago784 views
1 Answer
0

Your API is deployed on AWS Lambda, which means that the container is launched for you when needed.

But what is more important is that before your API there is AWS API Gateway to route HTTP calls to your API.

You can configure CORS on API Gateway. Instruction can be found here.

profile picture
MG
answered 2 years ago
  • First of all thank you very much for the response. The thing is I do not have a single thing listed under AWS Lambda or under API Gateway.

    The only thing I can find listed is the bucket I created when deploying the app for the first time. And that's under S3 -> Buckets. Otherwise, nothing.

  • Matt, check the region where the resources are deployed through your VS 2019. In the AWS console make sure you are in that right region.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions