fix: reverse proxy fails for some requests

This commit is contained in:
DIYgod
2023-07-24 01:04:46 +01:00
parent 541cae4397
commit 3da47b69ed
+9 -1
View File
@@ -42,8 +42,16 @@ if (agent) {
proxyWrapper = (url, options) => {
const urlIn = options.url?.toString() || url;
const proxyRegex = new RegExp(proxyObj.url_regex);
if (proxyRegex.test(urlIn) && !urlIn.startsWith(config.reverseProxyUrl) && !options.cookieJar) {
if (proxyRegex.test(urlIn) && !urlIn.startsWith(config.reverseProxyUrl) && !options.cookieJar && !options.headers['user-agent'].startsWith('PixivIOSApp')) {
options.url = new URL(`${config.reverseProxyUrl}${encodeURIComponent(urlIn)}`);
// remove cloudflare headers
for (const prop in options.headers) {
if (prop.startsWith('cf-') || prop === 'x-real-ip' || prop === 'x-forwarded-for' || prop === 'x-forwarded-proto') {
delete options.headers[prop];
}
}
return true;
}
return false;