Closed BaukePalstra closed 4 years ago
I added a test that shows this is working - can you double-check? https://github.com/dougmoscrop/serverless-http/blob/master/test/spec.js#L400
Sorry for the late reply. I see that in the 2.3.1 (title wrongfully says 2.3.0) version, writeHead wasn't working. I've added your test to that version (locally), but it errs:
Indeed looks like everything is ok in the latest version 👍
Great! So OK to close this?
When implementing
res.writeHead
, I get no headers back in my response:(req, res) => { res.writeHead(301, { Location: ' /foo', }) res.end()
} results in this response:{ "statusCode": 301, "headers": {}, "isBase64Encoded": false, "body": "" }
This is working fine without serverless http (ServerResponse instead of ServerlessResponse).
I suspect it has to do with https://github.com/dougmoscrop/serverless-http/blob/master/lib/response.js#L41, since the key is named
_header
, instead of_headers
.Refactoring to
res.setHeader('Location', ' /foo') res.statusCode = 301 res.end()
does give the response I expect