...**/!(*.map|*.min.js)Size
Gzip
Dependencies
Publish
Install
Publish
Install
Size
Gzip
Dependencies
@@ -50,6 +50,7 @@ | ||
| 50 | 50 | rewrite?: boolean | AxiosHeaderMatcher |
| 51 | 51 | ): AxiosHeaders; |
| 52 | 52 | set(headers?: axios.RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; |
| 53 | set(headers?: Iterable<[string, axios.AxiosHeaderValue]>, rewrite?: boolean): AxiosHeaders; | |
| 53 | 54 | |
| 54 | 55 | get(headerName: string, parser: RegExp): RegExpExecArray | null; |
| 55 | 56 | get(headerName: string, matcher?: true | AxiosHeaderParser): axios.AxiosHeaderValue; |
@@ -119,6 +120,8 @@ | ||
| 119 | 120 | |
| 120 | 121 | getSetCookie(): string[]; |
| 121 | 122 | |
| 123 | toString(): string; | |
| 124 | ||
| 122 | 125 | [Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>; |
| 123 | 126 | } |
| 124 | 127 | |
@@ -165,7 +168,9 @@ | ||
| 165 | 168 | } |
| 166 | 169 | |
| 167 | 170 | declare class CanceledError<T> extends AxiosError<T> { |
| 171 | constructor(message?: string, config?: axios.InternalAxiosRequestConfig, request?: any); | |
| 168 | 172 | readonly name: 'CanceledError'; |
| 173 | __CANCEL__?: boolean; | |
| 169 | 174 | } |
| 170 | 175 | |
| 171 | 176 | declare class Axios { |
@@ -296,6 +301,12 @@ | ||
| 296 | 301 | LoopDetected = 508, |
| 297 | 302 | NotExtended = 510, |
| 298 | 303 | NetworkAuthenticationRequired = 511, |
| 304 | WebServerIsDown = 521, | |
| 305 | ConnectionTimedOut = 522, | |
| 306 | OriginIsUnreachable = 523, | |
| 307 | TimeoutOccurred = 524, | |
| 308 | SslHandshakeFailed = 525, | |
| 309 | InvalidSslCertificate = 526, | |
| 299 | 310 | } |
| 300 | 311 | |
| 301 | 312 | type InternalAxiosError<T = unknown, D = any> = AxiosError<T, D>; |
@@ -428,6 +439,8 @@ | ||
| 428 | 439 | dots?: boolean; |
| 429 | 440 | metaTokens?: boolean; |
| 430 | 441 | indexes?: boolean | null; |
| 442 | maxDepth?: number; | |
| 443 | Blob?: { new (...args: any[]): any }; | |
| 431 | 444 | } |
| 432 | 445 | |
| 433 | 446 | // tslint:disable-next-line |
@@ -625,6 +638,9 @@ | ||
| 625 | 638 | promise: Promise<Cancel>; |
| 626 | 639 | reason?: Cancel; |
| 627 | 640 | throwIfRequested(): void; |
| 641 | subscribe(listener: (cancel: Cancel | any) => void): void; | |
| 642 | unsubscribe(listener: (cancel: Cancel | any) => void): void; | |
| 643 | toAbortSignal(): AbortSignal; | |
| 628 | 644 | } |
| 629 | 645 | |
| 630 | 646 | interface CancelTokenSource { |
@@ -691,7 +707,7 @@ | ||
| 691 | 707 | } |
| 692 | 708 | |
| 693 | 709 | interface AxiosStatic extends AxiosInstance { |
| 694 | Cancel: CancelStatic; | |
| 710 | Cancel: typeof CanceledError; | |
| 695 | 711 | CancelToken: CancelTokenStatic; |
| 696 | 712 | Axios: typeof Axios; |
| 697 | 713 | AxiosError: typeof AxiosError; |
@@ -75,7 +75,19 @@ | ||
| 75 | 75 | class AxiosError extends Error { |
| 76 | 76 | static from(error, code, config, request, response, customProps) { |
| 77 | 77 | const axiosError = new AxiosError(error.message, code || error.code, config, request, response); |
| 78 | axiosError.cause = error; | |
| 78 | // Match native `Error` `cause` semantics: non-enumerable. The wrapped | |
| 79 | // error often carries circular internals (sockets, requests, agents), so | |
| 80 | // an enumerable `cause` makes structured loggers (pino/winston) and any | |
| 81 | // own-property walk throw "Converting circular structure to JSON". | |
| 82 | // Regression from #6982; see #7205. `__proto__: null` mirrors the | |
| 83 | // `message` descriptor below (prototype-pollution-safe descriptor). | |
| 84 | Object.defineProperty(axiosError, 'cause', { | |
| 85 | __proto__: null, | |
| 86 | value: error, | |
| 87 | writable: true, | |
| 88 | enumerable: false, | |
| 89 | configurable: true, | |
| 90 | }); | |
| 79 | 91 | axiosError.name = error.name; |
| 80 | 92 | |
| 81 | 93 | // Preserve status from the original error if not already set from response |
@@ -40,7 +40,11 @@ | ||
| 40 | 40 | const cookie = cookies[i].replace(/^\s+/, ''); |
| 41 | 41 | const eq = cookie.indexOf('='); |
| 42 | 42 | if (eq !== -1 && cookie.slice(0, eq) === name) { |
| 43 | return decodeURIComponent(cookie.slice(eq + 1)); | |
| 43 | try { | |
| 44 | return decodeURIComponent(cookie.slice(eq + 1)); | |
| 45 | } catch (e) { | |
| 46 | return cookie.slice(eq + 1); | |
| 47 | } | |
| 44 | 48 | } |
| 45 | 49 | } |
| 46 | 50 | return null; |
@@ -557,7 +557,17 @@ | ||
| 557 | 557 | const canceledError = composedSignal.reason; |
| 558 | 558 | canceledError.config = config; |
| 559 | 559 | request && (canceledError.request = request); |
| 560 | err !== canceledError && (canceledError.cause = err); | |
| 560 | if (err !== canceledError) { | |
| 561 | // Non-enumerable to match native Error `cause` semantics so loggers | |
| 562 | // don't recurse into circular fetch internals (see #7205). | |
| 563 | Object.defineProperty(canceledError, 'cause', { | |
| 564 | __proto__: null, | |
| 565 | value: err, | |
| 566 | writable: true, | |
| 567 | enumerable: false, | |
| 568 | configurable: true, | |
| 569 | }); | |
| 570 | } | |
| 561 | 571 | throw canceledError; |
| 562 | 572 | } |
| 563 | 573 | |
@@ -579,18 +589,23 @@ | ||
| 579 | 589 | } |
| 580 | 590 | |
| 581 | 591 | if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) { |
| 582 | throw Object.assign( | |
| 583 | new AxiosError( | |
| 584 | 'Network Error', | |
| 585 | AxiosError.ERR_NETWORK, | |
| 586 | config, | |
| 587 | request, | |
| 588 | err && err.response | |
| 589 | ), | |
| 590 | { | |
| 591 | cause: err.cause || err, | |
| 592 | } | |
| 592 | const networkError = new AxiosError( | |
| 593 | 'Network Error', | |
| 594 | AxiosError.ERR_NETWORK, | |
| 595 | config, | |
| 596 | request, | |
| 597 | err && err.response | |
| 593 | 598 | ); |
| 599 | // Non-enumerable to match native Error `cause` semantics so loggers | |
| 600 | // don't recurse into circular fetch internals (see #7205). | |
| 601 | Object.defineProperty(networkError, 'cause', { | |
| 602 | __proto__: null, | |
| 603 | value: err.cause || err, | |
| 604 | writable: true, | |
| 605 | enumerable: false, | |
| 606 | configurable: true, | |
| 607 | }); | |
| 608 | throw networkError; | |
| 594 | 609 | } |
| 595 | 610 | |
| 596 | 611 | throw AxiosError.from(err, err && err.code, config, request, err && err.response); |
@@ -42,14 +42,16 @@ | ||
| 42 | 42 | |
| 43 | 43 | // RFC 2397 section 3: default mediatype is text/plain;charset=US-ASCII |
| 44 | 44 | // Bare `data:,` leaves mime undefined; Blob normalises that to "" per spec. |
| 45 | let mime; | |
| 45 | let mime = ''; | |
| 46 | 46 | if (type) { |
| 47 | 47 | mime = params ? type + params : type; |
| 48 | 48 | } else if (params) { |
| 49 | 49 | mime = 'text/plain' + params; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | const buffer = Buffer.from(decodeURIComponent(body), encoding); | |
| 52 | const buffer = encoding === 'base64' | |
| 53 | ? Buffer.from(body, 'base64') | |
| 54 | : Buffer.from(decodeURIComponent(body), encoding); | |
| 53 | 55 | |
| 54 | 56 | if (asBlob) { |
| 55 | 57 | if (!_Blob) { |
@@ -1,5 +1,6 @@ | ||
| 1 | 1 | import platform from '../platform/index.js'; |
| 2 | 2 | import utils from '../utils.js'; |
| 3 | import AxiosError from '../core/AxiosError.js'; | |
| 3 | 4 | import isURLSameOrigin from './isURLSameOrigin.js'; |
| 4 | 5 | import cookies from './cookies.js'; |
| 5 | 6 | import buildFullPath from '../core/buildFullPath.js'; |
@@ -15,7 +16,7 @@ | ||
| 15 | 16 | return; |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | Object.entries(formHeaders).forEach(([key, val]) => { | |
| 19 | Object.entries(formHeaders || {}).forEach(([key, val]) => { | |
| 19 | 20 | if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) { |
| 20 | 21 | headers.set(key, val); |
| 21 | 22 | } |
@@ -65,10 +66,14 @@ | ||
| 65 | 66 | const username = utils.getSafeProp(auth, 'username') || ''; |
| 66 | 67 | const password = utils.getSafeProp(auth, 'password') || ''; |
| 67 | 68 | |
| 68 | headers.set( | |
| 69 | 'Authorization', | |
| 70 | 'Basic ' + btoa(username + ':' + (password ? encodeUTF8(password) : '')) | |
| 71 | ); | |
| 69 | try { | |
| 70 | headers.set( | |
| 71 | 'Authorization', | |
| 72 | 'Basic ' + btoa(username + ':' + (password ? encodeUTF8(password) : '')) | |
| 73 | ); | |
| 74 | } catch (e) { | |
| 75 | throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config); | |
| 76 | } | |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | 79 | if (utils.isFormData(data)) { |
@@ -143,7 +143,13 @@ | ||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) { |
| 146 | return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); | |
| 146 | if (useBlob && typeof _Blob === 'function') { | |
| 147 | return new _Blob([value]); | |
| 148 | } | |
| 149 | if (typeof Buffer !== 'undefined') { | |
| 150 | return Buffer.from(value); | |
| 151 | } | |
| 152 | throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT); | |
| 147 | 153 | } |
| 148 | 154 | |
| 149 | 155 | return value; |
@@ -79,7 +79,7 @@ | ||
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | 81 | function assertOptions(options, schema, allowUnknown) { |
| 82 | if (typeof options !== 'object') { | |
| 82 | if (typeof options !== 'object' || options === null) { | |
| 83 | 83 | throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); |
| 84 | 84 | } |
| 85 | 85 | const keys = Object.keys(options); |
@@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "axios", |
| 3 | "version": "1.18.0", | |
| 3 | "version": "1.18.1", | |
| 4 | 4 | "description": "Promise based HTTP client for the browser and node.js", |
| 5 | 5 | "main": "./dist/node/axios.cjs", |
| 6 | 6 | "module": "./index.js", |
@@ -87,8 +87,8 @@ | ||
| 87 | 87 | "Martti Laine (https://github.com/codeclown)", |
| 88 | 88 | "Xianming Zhong (https://github.com/chinesedfan)", |
| 89 | 89 | "Shaan Majid (https://github.com/shaanmajid)", |
| 90 | "Remco Haszing (https://github.com/remcohaszing)", | |
| 90 | 91 | "Willian Agostini (https://github.com/WillianAgostini)", |
| 91 | "Remco Haszing (https://github.com/remcohaszing)", | |
| 92 | 92 | "Rikki Gibson (https://github.com/RikkiGibson)" |
| 93 | 93 | ], |
| 94 | 94 | "sideEffects": false, |
@@ -1,5 +1,37 @@ | ||
| 1 | 1 | # Changelog |
| 2 | 2 | |
| 3 | ## v1.18.0 — June 13, 2026 | |
| 4 | ||
| 5 | This release hardens redirect and URL handling, improves the validateStatus configuration semantics, and includes updates to documentation, dependencies, and release metadata. | |
| 6 | ||
| 7 | ## 🔒 Security Fixes | |
| 8 | ||
| 9 | * **Redirect Header Safety:** Added Node HTTP adapter support for stripping caller-specified sensitive headers on cross-origin redirects, helping prevent custom auth headers such as API keys from leaking to another origin. (__#10892__) | |
| 10 | ||
| 11 | * **URL And Request Hardening:** Rejects malformed `http:` and `https:` URLs that omit `//` with `ERR_INVALID_URL`, while tightening prototype-pollution-safe config reads, stream size limits, FormData depth handling, data URL sizing, and local `NO_PROXY` matching. (__#11000__) | |
| 12 | ||
| 13 | ## 🐛 Bug Fixes | |
| 14 | ||
| 15 | * **Status Validation:** Added `transitional.validateStatusUndefinedResolves` so applications can opt in to treating `validateStatus: undefined` like the option was omitted, while `validateStatus: null` remains the explicit way to accept every status. (__#10899__) | |
| 16 | ||
| 17 | ## 🔧 Maintenance & Chores | |
| 18 | ||
| 19 | * **Documentation:** Published the v1.17.0 release notes, fixed a changelog typo, clarified the package update PR policy, and marked the `proxy` request config as Node.js-only in the advanced docs. (__#10984__, __#10988__, __#10992__, __#10995__) | |
| 20 | ||
| 21 | * **Dependencies:** Bumped `@babel/core`, `@babel/preset-env`, `@commitlint/cli`, `@commitlint/config-conventional`, `@rollup/plugin-babel`, `@rollup/plugin-commonjs`, `@vitest/browser`, `@vitest/browser-playwright`, `eslint`, `lint-staged`, `rollup`, `vitest`, and `actions/checkout`. (__#10989__, __#10996__, __#10997__) | |
| 22 | ||
| 23 | * **Release Metadata:** Prepared the 1.18.0 release by updating package metadata and the runtime `VERSION` value. (__#11003__) | |
| 24 | ||
| 25 | ## 🌟 New Contributors | |
| 26 | ||
| 27 | We are thrilled to welcome our new contributors. Thank you for helping improve axios: | |
| 28 | ||
| 29 | * __@drori12__ (__#10984__) | |
| 30 | * __@eyupcanakman__ (__#10899__) | |
| 31 | * __@Adi-Beker__ (__#10995__) | |
| 32 | ||
| 33 | [Full Changelog](https://github.com/axios/axios/compare/v1.17.0...v1.18.0) | |
| 34 | ||
| 3 | 35 | ## v1.17.0 — June 1, 2026 |
| 4 | 36 | |
| 5 | 37 | This release adds Node HTTP zstd decompression, hardens config and release workflows, and fixes authentication, header, proxy, and type-handling regressions. |
@@ -31,6 +31,7 @@ | ||
| 31 | 31 | rewrite?: boolean | AxiosHeaderMatcher |
| 32 | 32 | ): AxiosHeaders; |
| 33 | 33 | set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; |
| 34 | set(headers?: Iterable<[string, AxiosHeaderValue]>, rewrite?: boolean): AxiosHeaders; | |
| 34 | 35 | |
| 35 | 36 | get(headerName: string, parser: RegExp): RegExpExecArray | null; |
| 36 | 37 | get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue; |
@@ -91,6 +92,8 @@ | ||
| 91 | 92 | |
| 92 | 93 | getSetCookie(): string[]; |
| 93 | 94 | |
| 95 | toString(): string; | |
| 96 | ||
| 94 | 97 | [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>; |
| 95 | 98 | } |
| 96 | 99 | |
@@ -233,6 +236,12 @@ | ||
| 233 | 236 | LoopDetected = 508, |
| 234 | 237 | NotExtended = 510, |
| 235 | 238 | NetworkAuthenticationRequired = 511, |
| 239 | WebServerIsDown = 521, | |
| 240 | ConnectionTimedOut = 522, | |
| 241 | OriginIsUnreachable = 523, | |
| 242 | TimeoutOccurred = 524, | |
| 243 | SslHandshakeFailed = 525, | |
| 244 | InvalidSslCertificate = 526, | |
| 236 | 245 | } |
| 237 | 246 | |
| 238 | 247 | type UppercaseMethod = |
@@ -315,6 +324,8 @@ | ||
| 315 | 324 | dots?: boolean; |
| 316 | 325 | metaTokens?: boolean; |
| 317 | 326 | indexes?: boolean | null; |
| 327 | maxDepth?: number; | |
| 328 | Blob?: { new (...args: any[]): any }; | |
| 318 | 329 | } |
| 319 | 330 | |
| 320 | 331 | // tslint:disable-next-line |
@@ -538,7 +549,9 @@ | ||
| 538 | 549 | } |
| 539 | 550 | |
| 540 | 551 | export class CanceledError<T> extends AxiosError<T> { |
| 552 | constructor(message?: string, config?: InternalAxiosRequestConfig, request?: any); | |
| 541 | 553 | readonly name: 'CanceledError'; |
| 554 | __CANCEL__?: boolean; | |
| 542 | 555 | } |
| 543 | 556 | |
| 544 | 557 | export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>; |
@@ -564,6 +577,9 @@ | ||
| 564 | 577 | promise: Promise<Cancel>; |
| 565 | 578 | reason?: Cancel; |
| 566 | 579 | throwIfRequested(): void; |
| 580 | subscribe(listener: (cancel: Cancel | any) => void): void; | |
| 581 | unsubscribe(listener: (cancel: Cancel | any) => void): void; | |
| 582 | toAbortSignal(): AbortSignal; | |
| 567 | 583 | } |
| 568 | 584 | |
| 569 | 585 | export interface CancelTokenSource { |
@@ -716,7 +732,7 @@ | ||
| 716 | 732 | export function create(config?: CreateAxiosDefaults): AxiosInstance; |
| 717 | 733 | |
| 718 | 734 | export interface AxiosStatic extends AxiosInstance { |
| 719 | Cancel: CancelStatic; | |
| 735 | Cancel: typeof CanceledError; | |
| 720 | 736 | CancelToken: CancelTokenStatic; |
| 721 | 737 | Axios: typeof Axios; |
| 722 | 738 | AxiosError: typeof AxiosError; |