Bypass proxy on loopback IPs

This commit is contained in:
Ferenc Hammerl committed 2023-03-01 13:45:12 +00:00
1 parent 86b9ab12e0
commit edb73c217d
2 files changed
+28 -8

No files matched your search

+10
View File
@@ -25,6 +25,11 @@ export function checkBypass(reqUrl: URL): boolean {
return false
}
const reqHost = reqUrl.hostname
if (isLoopbackAddress(reqHost)) {
return true
}
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''
if (!noProxy) {
return false
@@ -66,3 +71,8 @@ export function checkBypass(reqUrl: URL): boolean {
return false
}
function isLoopbackAddress(host: string): boolean {
const hostUpper = host.toUpperCase()
return hostUpper === 'LOCALHOST' || hostUpper.startsWith('127.') || hostUpper.startsWith('::1')
}