mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Merge pull request #3754 from maxlajoie99/feature/experimental-proxy-support
Experimental proxy support by manually following redirects
This commit is contained in:
commit
eb505a0be7
@ -6,6 +6,7 @@ const util = require('util')
|
|||||||
const fs = require('./libs/fsExtra')
|
const fs = require('./libs/fsExtra')
|
||||||
const fileUpload = require('./libs/expressFileupload')
|
const fileUpload = require('./libs/expressFileupload')
|
||||||
const cookieParser = require('cookie-parser')
|
const cookieParser = require('cookie-parser')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
const { version } = require('../package.json')
|
const { version } = require('../package.json')
|
||||||
|
|
||||||
@ -54,7 +55,26 @@ class Server {
|
|||||||
global.XAccel = process.env.USE_X_ACCEL
|
global.XAccel = process.env.USE_X_ACCEL
|
||||||
global.AllowCors = process.env.ALLOW_CORS === '1'
|
global.AllowCors = process.env.ALLOW_CORS === '1'
|
||||||
|
|
||||||
if (process.env.DISABLE_SSRF_REQUEST_FILTER === '1') {
|
if (process.env.EXP_PROXY_SUPPORT === '1') {
|
||||||
|
// https://github.com/advplyr/audiobookshelf/pull/3754
|
||||||
|
Logger.info(`[Server] Experimental Proxy Support Enabled, SSRF Request Filter was Disabled`)
|
||||||
|
global.DisableSsrfRequestFilter = () => true
|
||||||
|
|
||||||
|
axios.defaults.maxRedirects = 0
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
(error) => {
|
||||||
|
if ([301, 302].includes(error.response?.status)) {
|
||||||
|
return axios({
|
||||||
|
...error.config,
|
||||||
|
url: error.response.headers.location
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else if (process.env.DISABLE_SSRF_REQUEST_FILTER === '1') {
|
||||||
Logger.info(`[Server] SSRF Request Filter Disabled`)
|
Logger.info(`[Server] SSRF Request Filter Disabled`)
|
||||||
global.DisableSsrfRequestFilter = () => true
|
global.DisableSsrfRequestFilter = () => true
|
||||||
} else if (process.env.SSRF_REQUEST_FILTER_WHITELIST?.length) {
|
} else if (process.env.SSRF_REQUEST_FILTER_WHITELIST?.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user