From 498de660bac1bffe15fef74a898c6d669794196a Mon Sep 17 00:00:00 2001 From: abias Date: Mon, 22 May 2023 18:10:16 -0400 Subject: [PATCH 1/5] User HTTP instead of HTTPS when fetching icon in docker internal network --- src/server/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 05988cf7..19deb9c4 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -356,7 +356,9 @@ export async function generateManifestBase64(site: Site) { async function fetchIconPng(iconUrl: string) { return await fetch( - iconUrl.replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) + iconUrl + .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) + .replace(/https/, "http") ) .then(res => res.blob()) .then(blob => blob.arrayBuffer()); From 7fbb12a4bde29d72c1bf55e0d0a954f19c863b4a Mon Sep 17 00:00:00 2001 From: abias Date: Mon, 22 May 2023 18:15:44 -0400 Subject: [PATCH 2/5] Add debug statement. --- src/server/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 19deb9c4..70041603 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -355,11 +355,11 @@ export async function generateManifestBase64(site: Site) { } async function fetchIconPng(iconUrl: string) { - return await fetch( - iconUrl - .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) - .replace(/https/, "http") - ) + const fetchIconUrl = iconUrl + .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) + .replace(/https/, "http"); + console.log(`PNG URL: ${fetchIconUrl}`); + return await fetch(fetchIconUrl) .then(res => res.blob()) .then(blob => blob.arrayBuffer()); } From fd39b21b12d815ca8388df4f8b727e09c7cb4965 Mon Sep 17 00:00:00 2001 From: abias Date: Mon, 22 May 2023 18:41:33 -0400 Subject: [PATCH 3/5] Revert "Add debug statement." This reverts commit 7fbb12a4bde29d72c1bf55e0d0a954f19c863b4a. --- src/server/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 70041603..19deb9c4 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -355,11 +355,11 @@ export async function generateManifestBase64(site: Site) { } async function fetchIconPng(iconUrl: string) { - const fetchIconUrl = iconUrl - .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) - .replace(/https/, "http"); - console.log(`PNG URL: ${fetchIconUrl}`); - return await fetch(fetchIconUrl) + return await fetch( + iconUrl + .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) + .replace(/https/, "http") + ) .then(res => res.blob()) .then(blob => blob.arrayBuffer()); } From 19408b26bf504d25b5d4addc4c8c620fda81bcd8 Mon Sep 17 00:00:00 2001 From: abias Date: Mon, 22 May 2023 18:42:05 -0400 Subject: [PATCH 4/5] Revert "User HTTP instead of HTTPS when fetching icon in docker internal network" This reverts commit 498de660bac1bffe15fef74a898c6d669794196a. --- src/server/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 19deb9c4..05988cf7 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -356,9 +356,7 @@ export async function generateManifestBase64(site: Site) { async function fetchIconPng(iconUrl: string) { return await fetch( - iconUrl - .replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) - .replace(/https/, "http") + iconUrl.replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) ) .then(res => res.blob()) .then(blob => blob.arrayBuffer()); From ee95bd05fb42049202ecdeb667c2be880717775b Mon Sep 17 00:00:00 2001 From: abias Date: Mon, 22 May 2023 19:15:11 -0400 Subject: [PATCH 5/5] Always replace host with internal host --- src/server/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 05988cf7..9d91f14d 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -356,7 +356,7 @@ export async function generateManifestBase64(site: Site) { async function fetchIconPng(iconUrl: string) { return await fetch( - iconUrl.replace(/https?:\/\/localhost:\d+/g, getHttpBaseInternal()) + iconUrl.replace(/https?:\/\/[^\/]+/g, getHttpBaseInternal()) ) .then(res => res.blob()) .then(blob => blob.arrayBuffer());