mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
fix cookies not being set when follow redirect = false (#6679)
* fix follow redirect cookies not being set * Set default value of followredirects in axios-instance Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Jeroen Vinke <jeroen.vinke@iddinkgroup.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -647,7 +647,8 @@ const runSingleRequest = async function (
|
||||
|
||||
let axiosInstance = makeAxiosInstance({
|
||||
requestMaxRedirects: requestMaxRedirects,
|
||||
disableCookies: options.disableCookies
|
||||
disableCookies: options.disableCookies,
|
||||
followRedirects: followRedirects
|
||||
});
|
||||
|
||||
if (request.ntlmConfig) {
|
||||
|
||||
@@ -71,7 +71,7 @@ const createRedirectConfig = (error, redirectUrl) => {
|
||||
* @see https://github.com/axios/axios/issues/695
|
||||
* @returns {axios.AxiosInstance}
|
||||
*/
|
||||
function makeAxiosInstance({ requestMaxRedirects = 5, disableCookies } = {}) {
|
||||
function makeAxiosInstance({ requestMaxRedirects = 5, disableCookies, followRedirects = true } = {}) {
|
||||
let redirectCount = 0;
|
||||
|
||||
/** @type {axios.AxiosInstance} */
|
||||
@@ -113,6 +113,14 @@ function makeAxiosInstance({ requestMaxRedirects = 5, disableCookies } = {}) {
|
||||
error.response.headers['request-duration'] = end - start;
|
||||
|
||||
if (redirectResponseCodes.includes(error.response.status)) {
|
||||
if (!followRedirects) {
|
||||
if (!disableCookies) {
|
||||
saveCookies(error.config.url, error.response.headers);
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
if (redirectCount >= requestMaxRedirects) {
|
||||
// todo: needs to be discussed whether the original error response message should be modified or not
|
||||
return Promise.reject(error);
|
||||
|
||||
Reference in New Issue
Block a user