[英]Serverless 502 Bad Gateway
我可以按照文檔創建一個簡單的無服務器函數,但是當我添加http
偵聽器時,我在嘗試訪問我的端點時不斷收到502 Bad Gateway
。
我該如何調試?
'use strict';
module.exports.hello = async (event, context) => {
return {
statusCode: 200,
body: {
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
},
};
};
無服務器.yaml
service: playing-with-serverless # NOTE: update this with your service name
provider:
name: aws
runtime: nodejs8.10
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
我已經部署了我的功能
$ sls deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (423 B)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............
Serverless: Stack update finished...
Service Information
service: playing-with-serverless
stage: dev
region: us-east-1
stack: playing-with-serverless-dev
api keys:
None
endpoints:
GET - https://1r5mt9wa63.execute-api.us-east-1.amazonaws.com/dev/hello
functions:
hello: playing-with-serverless-dev-hello
layers:
None
Serverless: Removing old service artifacts from S3...
卷曲
$ curl --request GET \
--url https://1r5mt9wa63.execute-api.us-east-1.amazonaws.com/dev/hello
{"message": "Internal server error"}%```
您需要在響應對象中對body
進行字符串化:
return {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event
})
};
請參閱文檔,專門Output Format of a Lambda Function for Proxy Integration
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.