From f535b05014692ee0dcbbe6e9b63fdf9aa7b9613f Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Mon, 17 Nov 2025 16:03:40 -0500 Subject: [PATCH] Add fallback for HTTP HEAD requests --- src/type/p5.Font.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/type/p5.Font.js b/src/type/p5.Font.js index 26fbdd4996..370af6ebdf 100644 --- a/src/type/p5.Font.js +++ b/src/type/p5.Font.js @@ -1480,7 +1480,15 @@ function font(p5, fn) { let isCSS = path.includes('@font-face'); if (!isCSS) { - const info = await fetch(path, { method: 'HEAD' }); + let info; + try { + info = await fetch(path, { method: 'HEAD' }); + } catch (e) { + // Sometimes files fail when requested with HEAD. Fallback to a + // regular GET. It loads more data, but at least then it's cached + // for the likely case when we have to fetch the whole thing. + info = await fetch(path); + } const isCSSFile = info.headers.get('content-type')?.startsWith('text/css'); if (isCSSFile) { isCSS = true;