diff --git a/packages/core/src/router.ts b/packages/core/src/router.ts index 9b143e0e3..1cce932f6 100644 --- a/packages/core/src/router.ts +++ b/packages/core/src/router.ts @@ -1,4 +1,4 @@ -import { default as Axios, AxiosResponse } from 'axios' +import { default as GlobalAxiosInstance, AxiosResponse } from 'axios' import debounce from './debounce' import { fireBeforeEvent, @@ -33,6 +33,8 @@ import { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url' const isServer = typeof window === 'undefined' +const AxiosInstance = GlobalAxiosInstance.create(); + export class Router { protected page!: Page protected resolveComponent!: PageResolver @@ -343,7 +345,7 @@ export class Router { const isPartial = !!(only.length || except.length) - Axios({ + AxiosInstance({ method, url: urlWithoutHash(url).href, data: method === 'get' ? {} : data, @@ -436,7 +438,7 @@ export class Router { } }) .catch((error) => { - if (!Axios.isCancel(error)) { + if (!GlobalAxiosInstance.isCancel(error)) { const throwException = fireExceptionEvent(error) if (this.activeVisit) { this.finishVisit(this.activeVisit)