Skip to content

Commit 352961e

Browse files
committed
fix
1 parent 2b12be1 commit 352961e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/font/src/google/fetch-css-from-google-fonts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export async function fetchCSSFromGoogleFonts(
2323
return mockedResponse
2424
}
2525

26+
// Retry the fetch a few times in case of network issues as some font files
27+
// are quite large:
28+
// https://github.com/vercel/next.js/issues/45080
2629
return retry(async () => {
2730
const controller =
2831
isDev && typeof AbortController !== 'undefined'
@@ -34,13 +37,14 @@ export async function fetchCSSFromGoogleFonts(
3437
const res = await fetchWithProxy(url, {
3538
signal: controller?.signal,
3639
headers: {
40+
// The file format is based off of the user agent, make sure woff2 files are fetched
3741
'user-agent':
3842
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
3943
},
4044
})
4145

4246
if (!res.ok) {
43-
throw new Error(
47+
nextFontError(
4448
`Failed to fetch font \`${fontFamily}\`.\nURL: ${url}\n\nPlease check if the network is available.`
4549
)
4650
}

0 commit comments

Comments
 (0)