API Gateway, Lambda and CORS

0

I am running a few Lambda functions behind a load balancer (i.e. the Load Balancer is the Lambda Function's "source") which I intend to access from a web based SPA. I'm using API Gateway to proxy requests to my load balancer for other services (containers on ECS), and i was hoping to do the same for my Lambda functions.

I've spent the past 2 days dealing with CORS issues with my containerized applications, and so, to avoid that when it comes to my lambda functions, I decided to ask here what might be the best path going forward.

I cannot use the Lambda Proxy integration on API Gateway. It tells me that I do not have any Lambda Functions in my region (I assume this may be because the Lambda functions are deployed in a VPC, but i am not 100% sure on that).

So, is it possible to access Lambda Functions via a Load Balancer through API Gateway proxy+ resources? My intuition says yes, but I'm running into CORS issues. If so, how can I manage CORS in this scenario?

2回答
1

To avoid CORS, i've had to create my own OPTIONS handler for each function. The cheapest is just to echo the ORIGIN header back as authorized via CORS. The better way is to have the api gateway on the same domain as the rest of the product. So in order to get rid of CORS errors I've used Cloudfront to forward requests to the API gateway.

The explanation of your setup is a little vague, it shouldn't matter if its in a container or not. CORS is all about browser action and if you are accessing a resource outside of the domain of your main web page.

If you are using a program outside of a web browser-like interface then you wouldn't have any CORS issues.

Rahly
回答済み 3年前
-2

Don't bother answering.

This product is effectively unusable. I will find another solution.

回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ