When a request fails, a 2nd retry (with axios-retry) fails due to the reason that the baseURL gets attached again.
e.g. first request (browserBaseURL is "/api")
/api/test fails
axios retries: /api/api/test
2nd retry: /api/api/api/test
How to test: just make a test with a failing endpoint and set browserBaseURL to '/api'.
regards
Simon
Is this bug fixed yet?
No, but you can overcome it by not providing a Baseurl and just provide the whole path to the request itself.
Facing the same issue, and is not related to retry-axios but to axios.
If you look at dispatchRequest.js in the axios source code you'll see near line 25.
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
If you don't use an absolute URL as baseURL, the config.url will be always combined with the baseURL.
This means that..
if you do window.axios.defaults.baseURL = '/v1/api/', the first time you execute a request, such as axios.get('/user') the actual url will be [config.baseURL] + [config.url] = '/v1/api/ + user' = '/v1/api/user'.
When that request is retried the code of dispatchRequest.js will be repeated, and now the value of url is already "prepended" with the baseURL. So the config.url will end up with [baseURL] + [url] = '/v1/api/ + /vi/api/user' = '/v1/api/v1/api/user'.
Solutions
baseURLconfig.URL if the request is being retriedOther bug in 0.19.0 : bug
Personnaly, i use axios retry and i can't use 0.19 branch because of this ....
Can you please verify if this is now fixed with last version of axios?
I tried, it works now 馃憤
Most helpful comment
I tried, it works now 馃憤