Skip to content

Commit

Permalink
feat: exclude some requests for reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jul 24, 2023
1 parent 3da47b6 commit 0300433
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/utils/request-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0300433

Please sign in to comment.