使用 Lambda AWS 的无服务器功能

Severless Function using Lambda AWS

我正在尝试遵循下面给出的 url。

https://aws.amazon.com/getting-started/projects/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/

我已成功完成所有步骤。但是当我尝试调用 Request Unicorn 时。我在控制台中收到以下错误。

Failed to load https://jvhlk3ly43.execute-api.ap-southeast-2.amazonaws.com/prod/ride: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://wildrydes-naveen-muralidharan.s3-website-ap-southeast-2.amazonaws.com' is therefore not allowed access. ride.js:34 Error requesting ride: error , Details: ajaxError @ ride.js:34 fire @ jquery-3.1.0.js:3243 fireWith @ jquery-3.1.0.js:3373 done @ jquery-3.1.0.js:9100 (anonymous) @ jquery-3.1.0.js:9332 error (async) send @ jquery-3.1.0.js:9360 ajax @ jquery-3.1.0.js:8999 requestUnicorn @ ride.js:19 handleRequestClick @ ride.js:87 dispatch @ jquery-3.1.0.js:5110 elemData.handle @ jquery-3.1.0.js:4918 ride.js:35 Response: undefined

谁能帮我配置 CORS。

CORS通常在API网关层完成,你只需要配置它并部署阶段

检查:https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html