You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constheaders=newHeaders()if(session.token)headers.set("Authorization",`Bearer ${session.token}`)elseconsole.warn(`[PROXY] No token set`)if(session.domain)headers.set("X-Domain",session.domain)elseconsole.warn(`[PROXY] No domain set`)// note: no 'Authorization' header in the event headersconstmergedHeaders=mergeHeaders(event.headers,headers)console.log(mergedHeaders.get("Authorization"))// log: undefined
Describe the bug
The mergeHeaders utility won't merge multiple instances of Headers. This is a result of the underlying logic using Object.entries to get a list of key-value pairs which returns an empty array on a Headers instance.
Since Headers satisfies the HeadersInit type, this should either work, or the types should be changed appropriately.
Once it's clear how we should continue, I will open a PR.
Additional context
I found this issue when trying to use the proxyRequest / sendProxy utility, basically all of the other utilities depending on mergeHeaders suffer from the type / logic issue and it's not that trivial to find, because you think something is wrong in your code.
Logs
No response
The text was updated successfully, but these errors were encountered:
I didn't want to create a PR as you said you would do so already, and I'm not sure if it's the direction you want to go either, but I made an attempt here: gemmadlou@019f0e8.
Since Headers satisfies the HeadersInit type, this should either work, or the types should be changed appropriately.
Once it's clear how we should continue, I will open a PR.
I saw this note but noted that Object.entries(input!) didn't do anything if the input was instanceof Headers.
This is a result of the underlying logic using Object.entries to get a list of key-value pairs which returns an empty array on a Headers instance.
I guess I will open a pull request in the next few days which will fix this
I get you now. 👍 Of course. Makes senses. And thanks for the PR. In my version, I was just trying to understand the underlying problem. In the meantime, there's nothing stopping from not using the Header object.
Environment
Nuxt 3.12.2 with Nitro 2.9.6
development mode
Reproduction
Describe the bug
The
mergeHeaders
utility won't merge multiple instances of Headers. This is a result of the underlying logic using Object.entries to get a list of key-value pairs which returns an empty array on a Headers instance.Since
Headers
satisfies theHeadersInit
type, this should either work, or the types should be changed appropriately.Once it's clear how we should continue, I will open a PR.
Additional context
I found this issue when trying to use the proxyRequest / sendProxy utility, basically all of the other utilities depending on mergeHeaders suffer from the type / logic issue and it's not that trivial to find, because you think something is wrong in your code.
Logs
No response
The text was updated successfully, but these errors were encountered: