Closed patrickdevivo closed 1 month ago
I also ran into this recently. From what I can tell, at some point (I think in this commit), graphql-request started using the Headers
object as opposed to a plain JS object
- const headers = { ...params.headers }
+ const headers = new Headers(params.headers as HeadersInit)
In my use-case, I was originally modifying and passing headers in a request middleware as such:
const requestMiddleware: RequestMiddleware = async (request) => {
return {
...request,
headers: {
...request.headers,
Authorization: `Bearer ${await getToken()}`,
},
};
};
After the change in the above commit, the resulting headers that are passed look something to the effect of:
{
headers: {
Authorization: '<token>',
[Symbol(headers list)]: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: [Array]
},
[Symbol(guard)]: 'none'
}
}
at which point I believe the error is thrown.
For me, I simply changed from spreading the headers to constructing a new Headers
object and then using headers.set("Authorization", token)
.
I'm not sure if this is the same issue as your use-case based on the context provided but thought I'd share
Screenshot
Description
I recently upgraded from
v6.1.0
tov7.0.1
and my Next.js app began encountering the above error (though only when running in development mode):I'm wondering if anyone has ideas what could be causing this, and if there's some breaking change that I need to adapt to? Thanks!
Reproduction Steps/Repo Link
N/A