feat: exclude some requests for reverse proxy
This commit is contained in:
@@ -42,16 +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 && !options.headers['user-agent'].startsWith('PixivIOSApp')) {
|
||||
if (
|
||||
proxyRegex.test(urlIn) &&
|
||||
!urlIn.startsWith(config.reverseProxyUrl) &&
|
||||
!options.cookieJar &&
|
||||
!options.headers['user-agent']?.startsWith('PixivIOSApp') &&
|
||||
!options.headers['x-goog-api-client'] &&
|
||||
!options.headers.accept === 'application/dns-json'
|
||||
) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user