elysiajs / eden

Fully type-safe Elysia client
MIT License
147 stars 37 forks source link

Makes sure the headers are processed right before making a request #101

Open mrctrifork opened 3 months ago

mrctrifork commented 3 months ago

The bug occurs because treaty "lower cases" all header values (not sure exactly why; I'd do nothing to them and let the platform handle the logic)

Since seems that some code got copy-pasted; and the latter appearance of the code copy-pasted code didn't process the headers it accumulated the headers as follows:

// headers
{
  authorization: 'Bearer token',
  Authorization: 'Bearer token'
}
const request = new Request({
    headers: {
        authorization: 'Bearer token',
        Authorization: 'Bearer token'
    }
})

console.log(request.header.get('Authorization')) // prints "Bearer token, Bearer token"

The fix is to remove the duplicated logic at the top and ensure "processHeaders" gets called.

closes #100