From 4df2ca25a44565184ebcd0f40826cef33e3c6774 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 27 Feb 2025 16:52:00 -0800 Subject: [PATCH] Support HOMEPAGE_PROXY_DISABLE_IPV6 --- docs/installation/index.md | 12 +++++++++++- src/utils/proxy/http.js | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/installation/index.md b/docs/installation/index.md index dd8c18f3d..db5968535 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -27,6 +27,16 @@ You have a few options for deploying homepage, depending on your needs. We offer +## Environment Variables + ### `HOMEPAGE_ALLOWED_HOSTS` -As of v1.0 there is one required environment variable when deploying via a public URL, HOMEPAGE_ALLOWED_HOSTS. This is a comma separated (no spaces) list of allowed hosts (sometimes with the port) that can access your homepage. See the [docker](docker.md) and [source](source.md) installation pages for examples. +Required. + +As of v1.0 there is one required environment variable when deploying via a public URL, HOMEPAGE_ALLOWED_HOSTS. This is a comma separated list of allowed hosts that can access your homepage. See the [docker](docker.md) and [source](source.md) installation pages for examples. + +### `HOMEPAGE_PROXY_DISABLE_IPV6` + +Optional. + +In certain environments, you may need to disable IPv6 for the proxy to work correctly. Set this environment variable to `true` to disable IPv6. diff --git a/src/utils/proxy/http.js b/src/utils/proxy/http.js index 3743515b4..3647f15b9 100644 --- a/src/utils/proxy/http.js +++ b/src/utils/proxy/http.js @@ -83,18 +83,18 @@ export function httpRequest(url, params) { export async function httpProxy(url, params = {}) { const constructedUrl = new URL(url); + const disableIpv6 = process.env.HOMEPAGE_PROXY_DISABLE_IPV6 === "true"; + const agentOptions = disableIpv6 ? { family: 4, autoSelectFamily: false } : {}; let request = null; if (constructedUrl.protocol === "https:") { request = httpsRequest(constructedUrl, { - agent: new https.Agent({ - rejectUnauthorized: false, - }), + agent: new https.Agent({ ...agentOptions, rejectUnauthorized: false }), ...params, }); } else { request = httpRequest(constructedUrl, { - agent: new http.Agent(), + agent: new http.Agent(agentOptions), ...params, }); }