mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-20 02:39:38 +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
2985f279c6
commit
bcfcc74531
1 changed files with 17 additions and 0 deletions
|
|
@ -128,6 +128,23 @@ class Server {
|
|||
}
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue