Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(preset-web-fonts): use woff2 compatible user-agent #2114

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/preset-web-fonts/src/index.ts
Original file line number Diff line number Diff line change
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