【发布时间】:2021-05-19 23:53:17
【问题描述】:
我创建了一个无服务器项目,但遇到了问题:
sls create --template aws-nodejs-typescript
npm install serverless-offline --save-dev
然后,在我添加的文件 serverless.ts 中:
plugins: ['serverless-webpack', 'serverless-offline'],
所以我使用以下命令运行项目:
serverless offline --stage dev
作为回应,我有:
**POST | http://localhost:3000/dev/hello
POST | http://localhost:3000/2015-03-31/functions/hello/invocations**
POST http://localhost:3000/dev/hello using body {“name”: “Andre”} 的请求不响应,我不知道为什么项目不响应请求,它只在邮递员中显示“发送请求”并不断显示。但是如果我使用地址 GET http://localhost:3000 我有一个响应说现有的路由是:
{
"currentRoute": "get - /",
"error": "Serverless-offline: route not found.",
"existingRoutes": [
"post - /dev/hello"
],
"statusCode": 404
}
请问,你能做这个过程吗?我认为创建的模板中有错误
谢谢。
【问题讨论】:
标签: node.js typescript api rest serverless