mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Use experimental DNS resolution on redirects
This change disables axios' built-in redirect handling and instead handles redirects manually. This ensures that the experimental DNS resolution works on redirects too, and not just on the initial request.
This commit is contained in:
parent
9d017a2b85
commit
27cba5c88a
1 changed files with 17 additions and 0 deletions
|
|
@ -128,6 +128,23 @@ class Server {
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Manually handle redirects, otherwise axios would bypass custom dns resolution on redirects
|
||||||
|
axios.defaults.maxRedirects = 0
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
async (error) => {
|
||||||
|
if (error.response && [301, 302, 303, 307, 308].includes(error.response.status) && error.response.headers.location) {
|
||||||
|
const redirectUrl = error.response.headers.location
|
||||||
|
Logger.debug(`[Server] Following ${error.response.status} redirect to ${redirectUrl}`)
|
||||||
|
return axios({
|
||||||
|
...error.config,
|
||||||
|
url: redirectUrl
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
global.PodcastDownloadTimeout = toNumber(process.env.PODCAST_DOWNLOAD_TIMEOUT, 30000)
|
global.PodcastDownloadTimeout = toNumber(process.env.PODCAST_DOWNLOAD_TIMEOUT, 30000)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue