Preflight checklist
Ory Network Project
No response
Describe the bug
When using @ory/client-fetch, the toSession() method allows passing a cookie parameter as part of requestParameters, which correctly sets the Cookie header — unless initOverrides.headers is also provided. In that case, the SDK silently overwrites the Cookie header with the contents of initOverrides.headers, leading to unexpected 401 Unauthorized response.
Reproducing the bug
const session = await api.toSession(
{ cookie },
{
headers: {
'Cache-Control': 'max-age=0'
}
}
);
Expected behavior:
The request sends both Cookie and Cache-Control headers
Actual behavior:
Only Cache-Control is sent. Cookie is silently overwritten. Request fails with 401 Unauthorized.
Workaround
Manually add the cookie into headers:
const session = await api.toSession(
{ cookie },
{
headers: {
'Cache-Control': 'max-age=0',
'Cookie': cookie
}
}
);
Relevant log output
Relevant configuration
Version
"@ory/client-fetch": "1.22.4"
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response