aws-serverless-express-edge icon indicating copy to clipboard operation
aws-serverless-express-edge copied to clipboard

hostHeader.startsWith is not a function

Open dfloresgonz opened this issue 4 years ago • 5 comments

I get this error. I cannot access the _http_agent.js I don't have that file. Is there a way to solve this?

hostHeader.startsWith is not a function
    at calculateServerName (_http_agent.js:240:20)
    at Agent.addRequest (_http_agent.js:155:26)
    at new ClientRequest (_http_client.js:258:16)
    at Object.request (http.js:42:10)
    at forwardRequestToNodeServer (/var/task/node_modules/aws-serverless-express-edge/index.js:129:26)
    at Object.proxy (/var/task/node_modules/aws-serverless-express-edge/index.js:188:9)

dfloresgonz avatar Mar 12 '20 17:03 dfloresgonz

@dfloresgonz The cause of the problem is that the request header is an object. As I fixed this problem, please see below. https://github.com/Karibash/aws-serverless-express-edge/commit/d4a80f14b39e33d8822f44d8267629818ae2030c

Karibash avatar Mar 14 '20 13:03 Karibash

were you able to get it working? I wrote my own module that does what this package does, but I keep getting a timeout when it does http.request(options, ...)

erichaus avatar Mar 21 '20 01:03 erichaus

I had to modify the library: in the function mapEdgeEventToHttpRequest I added: headers.host = headers.host[0].value;

dfloresgonz avatar Mar 21 '20 01:03 dfloresgonz

@dfloresgonz did you get it actually working though? I'm getting socket hangup (ECONNRESET on "http.request()"), just curious if it's indeed possible to run express on lambda@edge!

erichaus avatar Mar 22 '20 18:03 erichaus

@burritoland well I'm not sure yet I don't get the error anymore but my page is blank but no error in the browser console.

dfloresgonz avatar Mar 22 '20 19:03 dfloresgonz