From d9f4fae05568af1f6b4ca6fbc7f2dcf8fd55a77e Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 1 Apr 2024 13:17:50 +0100 Subject: [PATCH] fix: handle custom `app.baseURL` in development resolves https://github.com/nuxt/fonts/issues/96 --- src/assets.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/assets.ts b/src/assets.ts index fff3ba5..f99c2cc 100644 --- a/src/assets.ts +++ b/src/assets.ts @@ -5,7 +5,7 @@ import { fetch } from 'node-fetch-native/proxy' import chalk from 'chalk' import { defu } from 'defu' import type { NitroConfig } from 'nitropack' -import { hasProtocol, joinURL } from 'ufo' +import { hasProtocol, joinRelativeURL, joinURL } from 'ufo' import { extname, join } from 'pathe' import { filename } from 'pathe/utils' import { hash } from 'ohash' @@ -38,7 +38,9 @@ export function setupPublicAssetStrategy (options: ModuleOptions['assets'] = {}) renderedFontURLs.set(file, source.url) source.originalURL = source.url - source.url = joinURL(assetsBaseURL, file) + source.url = nuxt.options.dev + ? joinRelativeURL(nuxt.options.app.baseURL, assetsBaseURL, file) + : joinURL(assetsBaseURL, file) } return source })