I'm following the documentation in order to set response headers. I'm doing so because CORS is not letting me do anything.
Anyways, the docs ( https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#responses ) says I can do it like this:
events:
- http:
method: get
path: whatever
response:
headers:
Content-Type: "'text/html'"
However, it seems like the docs aren't up to date because serverless is complaining when deploying, Serverless: Configuration warning at 'functions.myFunction.events[1].httpApi': unrecognized property 'response'
How do you set response headers in the newest version?
Thanks!
That error appears to be coming from an httpApi
event, not the http
event you included in your question. Do you perhaps have another event with the type httpApi
elsewhere in your serverless.yaml
? If so, it will break if you include a response
in it because it uses a different schema than the regular http
event type.
Docs on httpApi
events: https://www.serverless.com/framework/docs/providers/aws/events/http-api/
Docs on http
events: https://www.serverless.com/framework/docs/providers/aws/events/apigateway/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.