In the React app I’m working on we create an zodios instance and set custom headers as part of axiosConfig:
export function createApiClient(url: string, options?: ZodiosOptions) {
return new Zodios(url, endpoints, options);
}
const apiClient = createApiClient(url, {
axiosConfig: {
headers: {
"header1": "header1",
"header2": "header2",
},
withCredentials: true,
},
});
We also want cookies to be passed with every request. In this configuration, they are not passed. However, if we remove custom headers from axios config, like so:
const apiClient = createApiClient(url, {
axiosConfig: {
withCredentials: true,
},
});
The cookies are passed.
We need both cookies and custom headers. What could be the issue here? We use zodios to enforce type safety, could it be possible that there’s some zodios setting that makes this happen?
I’ve tried tweaking the zodios schema and creating an axios instance directly instead of wrapping it into zodios – that didn’t help.
Thank you in advance, and let me know if there’s some more info I need to add to the question.