-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicated URL params #280
Comments
i have the same problem. i update the newest version. this still happened |
I temporarily used the following method to avoid this issue. I'm not sure if there's a better way to handle it. instance.interceptors.request.use(conf => {
const config: InternalAxiosRequestConfig = { ...conf };
// set request id
const requestId = nanoid();
config.headers.set(REQUEST_ID_KEY, requestId);
// retry bug fix
clearDuplicatedQueryString(config);
// config cancel token
const cancelTokenSource = axios.CancelToken.source();
config.cancelToken = cancelTokenSource.token;
cancelTokenSourceMap.set(requestId, cancelTokenSource);
// handle config by hook
return opts.onRequest?.(config) || config;
});
// Clear duplicate query string parameters
function clearDuplicatedQueryString(config: InternalAxiosRequestConfig) {
const isAbsoluteURL = /^https?:\/\//i.test(config.url!);
if (isAbsoluteURL) config.params = {};
} |
On the first request it will return config.url with just the path - But when I log the response from on
requestConfig.url returns the absolute url; tried to track down if it's axios-retry or axios that is changing the url from a path to absolute but was unable to |
can i ask, how are you guys forming the url like
i can't seem to figure out 🙈 |
在请求拦截器中添加以下代码,可以优雅的解决你的问题 instance.interceptors.request.use(config => {
config.url = config.url.split('?')[0]
return config;
}); |
First request will be:
/api?foo=bar
Second:
/api?foo=bar&foo=bar
...
The text was updated successfully, but these errors were encountered: