Skip to content

Commit 54cbcd2

Browse files
committed
fix: add slash separator and semicolon in @font-face CSS
The @fs URL prefix was concatenated directly with the font file path, creating invalid URLS like `/@fsc:/path` insted of `/@fs/C:path`. Additionally, the src property was missing a semicolon, causing CSS parsing errors and preventing font requests from being made. This caused 404 errors and font loading failures in dev mode.
1 parent e9d54b8 commit 54cbcd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/plugins/next-font/local/get-font-face-declarations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions) {
7272
if ("fontReferenceId" in localFontSrc) {
7373
return dedent`@font-face {
7474
font-family: ${id};
75-
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs${localFontSrc.fontPath}`})
75+
src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs/${localFontSrc.fontPath}`});
7676
${fontDeclarations}
7777
}`;
7878
}
@@ -86,7 +86,7 @@ export async function getFontFaceDeclarations(options: LoaderOptions) {
8686
.map((font) => {
8787
return dedent`@font-face {
8888
font-family: ${id};
89-
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs${font.path.fontPath}`});
89+
src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs/${font.path.fontPath}`});
9090
${font.weight ? `font-weight: ${font.weight};` : ""}
9191
${font.style ? `font-style: ${font.style};` : ""}
9292
${fontDeclarations}

0 commit comments

Comments
 (0)