express - Lambda 在请求正文中返回标头
问题描述
我正在使用无服务器在 lambda 中部署我的 express js 应用程序。奇怪的是,一些 api 在响应正文中返回标头,我不确定为什么会这样。这是我的无服务器 YAML 文件:
org: test
app: test-api
# serverless.yml
service: test-api
package:
exclude:
#- node_modules/**
- __tests__/**
provider:
name: aws
runtime: nodejs10.x
region: us-east-1
environment:
SERVICE_NAME: ${self:service}
plugins:
- serverless-domain-manager
custom:
stage: ${opt:stage, dev}
domains:
prod: api.test.com
dev: dev-api.test.com
customDomain:
basePath: "${self:provider.environment.SERVICE_NAME}"
domainName: ${self:custom.domains.${self:custom.stage}}
stage: "${self:custom.stage}"
createRoute53Record: true
functions:
test-api:
handler: build/app.handler
environment:
stage: ${self:custom.stage}
events:
- http:
path: v1/s
method: GET
cors: true
- http:
path: v1/sc
method: GET
cors: true
- http:
path: v1/s/{s}
method: GET
cors: true
- http:
path: v1/cs
method: POST
cors: true
- http:
path: v1/s
method: POST
cors: true
- http:
path: v1/s/{s}
method: DELETE
cors: true
- http:
path: v1/s/{s}
method: PUT
cors: true
这是响应的样子:
curl -d '{"c":"test"}' -H "Content-Type: application/json" -X POST https://dev-api.test.com/test-api/v1/cs
HTTP/1.1 200 Not Modified
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: sessionId
Vary: Origin
Content-Type: application/json; charset=utf-8
Content-Length: 55
ETag: W/"37-vmzwGqI9Wb8ACGS7qhhE3/JBqt4"
Date: Fri, 24 Apr 2020 12:30:41 GMT
Connection: keep-alive
{"rsp":{"msg":{"s":[],"c":{}},"err":null}
知道它是无服务器 yaml 还是其他配置?
解决方案
我能够解决这个问题,联系了无服务器支持,他们说有一个错误,现在它已经修复了。只需要更新无服务器就解决了!
推荐阅读
- coq - 如何在 coq 中明确使用归纳原则?
- reactjs - 如何在反应js中以编程方式关闭引导模式
- python - 在文本中逐行查找多个正则表达式(存储在文件中)(存储在另一个文件中)
- java - SpringApplication.run() 之后部署到 Tomcat 的 Spring Boot WAR 忽略了代码
- tensorflow - RAM 耗尽过快
- javascript - RxJS 运算符将可观察对象组合成状态?
- python - Pandas 数据透视表给出“FutureWarning:排序,因为非连接轴未对齐”
- laravel - laravel 在 aws 中的官方部署
- java - 如何从父抽象类调用子类方法
- json - 如何使用 Perl 在 Redmine 中创建问题