API gateway跨域问题

0

我在S3部署了一个前端页面,代码中会去GET访问我的一个api gateway,API gateway根据不同的访问路径,执行后端不同的lambda。 为了避免跨域问题,我在API gateway配置了允许跨域,如图: Enter image description here

但是在访问后端的时候仍然报错跨域

Enter image description here

asked 10 months ago197 views
2 Answers
0

以下文档表明,后端Lambda代码需要一个头来允许CORS。
兰姆达代码看起来像以下文件吗?
https://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/how-to-cors.html#apigateway-cors-request-types

profile picture
EXPERT
answered 10 months ago
0

在返回值的地方需要加上下面的代码 response["headers"]["Access-Control-Allow-Origin"] = "*"

zhangxq
answered 10 months ago

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