persiliao/axios-tauri-api-adapter

Additional `set-cookie` headers get discarded

Closed this issue · 0 comments

piksel commented

Hello!

As it is common to send multiple set-cookie: headers in a response (and because the Tauri cookie handling is inconsistent at best), the adapter should probably support multiple headers with the set-cookie key. The type of the AxiosResponse.headers actually specify that when using the key set-cookie, the value is string[] | undefined.
Ref: axios/axios#874

Currently, the headers are just mapped from the tauri Response.headers where every header value is just a string (and only the first (?) value will be present). The easiest fix is just to substitute the value from Response.rawHeaders for set-cookie, like this:

const headers = {
	...response.headers,
	'set-cookie': response.rawHeaders['set-cookie'],
}

This would enable manual cookie management in the application code when necessary.