Skip to content

Commit

Permalink
feat(preset-web-fonts): use woff2 compatible user-agent (#2114)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xb4lint committed Jan 27, 2023
1 parent 3616166 commit b77979e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/preset-web-fonts/src/index.ts
Expand Up @@ -49,9 +49,10 @@ const preset = (options: WebFontsOptions = {}): Preset<any> => {
async function importUrl(url: string) {
if (inlineImports) {
if (!importCache[url]) {
const userAgentWoff2 = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
const promise = customFetch
? customFetch(url)
: (await import('ohmyfetch')).$fetch(url, { headers: {}, retry: 3 })
: (await import('ohmyfetch')).$fetch(url, { headers: { 'User-Agent': userAgentWoff2 }, retry: 3 })
importCache[url] = promise.catch((e) => {
console.error('Failed to fetch web fonts')
console.error(e)
Expand Down

0 comments on commit b77979e

Please sign in to comment.