Next.js Discord

Discord Forum

"public/humansans/HumanSans-Regular.woff2" not being seen my nextjs

Unanswered
Grand Griffon Vendéen posted this in #help-forum
Open in Discord
Avatar
Grand Griffon VendéenOP
nextjs is unable to see a font file located in public, but if I put that file inside the app folder, it works.

Server Error
Error: Expected font file content

Debug info:
- Execution of get_written_endpoint_with_issues failed
- Execution of Issue::into_plain failed
- Execution of <ResolvingIssue as Issue>::detail failed
- Execution of <NextFontLocalReplacer as ImportMappingReplacement>::result failed
- Execution of get_font_css_properties failed
- Execution of get_font_fallbacks failed
- Expected font file content

My code:
const human_sans = localFont({
  variable: '--human',
  display: 'auto',
  src: '/humansans/HumanSans-Regular.woff2',
})
Image

5 Replies

Avatar
try
const human_sans = localFont({
  variable: '--human',
  display: 'auto',
  src: './public/humansans/HumanSans-Regular.woff2',
})
Avatar
Grand Griffon VendéenOP
already did, doesn't work
Avatar
ok try
const human_sans = localFont({
  variable: '--human',
  display: 'auto',
  src: '../../public/humansans/HumanSans-Regular.woff2',
})
Avatar
Grand Griffon VendéenOP
it worked thank you :D

I still would love to know why nextjs sees other folders in public without doing ../../ tho
Avatar
look like the src expect a relative path and it will load the font from where localFont is defined