CORS settings having no effect on AWS Lambda WebApi 2.0 Controllers in local dev environment

Multi tool use
CORS settings having no effect on AWS Lambda WebApi 2.0 Controllers in local dev environment
I have a very peculiar problem.
Is there a restriction on CORS and the number of controllers in a single Lambda function for the .NET core?
Edit 1 : Adding code segments for better illustration
In ConfigureServices
var origins = Configuration.GetSection("AllowedCORS").AsEnumerable().Select(x => x.Value);
services.AddCors(o => o.AddPolicy("AllOrigins", builder =>
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
}));
Then in Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors("AllOrigins");
app.UseAuthentication();
app.UseMvc();
}
1 Answer
1
I managed to resolve the issue by manually adding an Options handler in the controller and returning 200 OK.
Lambda does allow users to enable CORS but for some reason that method did not work for me (too many errors during setup)
At present i am restricting one Lambda function to one controller thereby giving me the freedom to modify only a certain set of the APIs.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you please post the code to show how you have added CORS setting?
– user1672994
Jul 3 at 4:47