Skip to content

Commit 89e9f59

Browse files
authored
Preserve headers on HTTP redirects in axios (#3401)
1 parent 8a37b6b commit 89e9f59

File tree

1 file changed

+10
-2
lines changed
  • src/server/components/charts-engine/components/request

1 file changed

+10
-2
lines changed

src/server/components/charts-engine/components/request/axios.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,20 @@ export class RequestAxios {
432432
}
433433

434434
private static mapRequestOptions(options: RequestOptions): AxiosRequestConfig {
435+
const normalizedHeaders = normalizeHeaders(options.headers);
436+
435437
const axiosConfig: AxiosRequestConfig = {
436438
url: options.uri || options.url,
437439
method: options.method,
438-
headers: normalizeHeaders(options.headers),
440+
headers: normalizedHeaders,
439441
timeout: options.timeout,
440-
maxRedirects: options.maxRedirects ?? 10,
442+
maxRedirects: options.maxRedirects ?? 0,
443+
beforeRedirect: (redirectOptions) => {
444+
// Preserve all original headers on redirect (matches request-promise-native behavior)
445+
if (normalizedHeaders) {
446+
Object.assign(redirectOptions.headers, normalizedHeaders);
447+
}
448+
},
441449
};
442450

443451
if (options.body !== undefined) {

0 commit comments

Comments
 (0)