How to load assets in route handlers?
Answered
Chestnut-backed Chickadee posted this in #help-forum
Chestnut-backed ChickadeeOP
I want to load a font for some image manipulation that im doing with jimp. But its not able to load the font file at all. Where can I find documentation/example for this?
Answered by joulev
Route handler is run in a different place from static assets on Vercel, so fs doesn’t work. I would just fetch() the font file and use the returned buffer to supply to jimp
7 Replies
Chestnut-backed ChickadeeOP
This is what im doing right now
const filePath = path.join(process.cwd(), 'public', 'open-sans-64-white.fnt')
const font = await jimp.loadFont(filePath)which results in
no such file or directoryyou can just import the font from
next/font import { Open_Sans } from "next/font/google"@Shaurya you can just import the font from `next/font` tsx
import { Open_Sans } from "next/font/google"
Chestnut-backed ChickadeeOP
im not using it for frontend code, I need the file directly
oh
@Chestnut-backed Chickadee I want to load a font for some image manipulation that im doing with jimp. But its not able to load the font file at all. Where can I find documentation/example for this?
Route handler is run in a different place from static assets on Vercel, so fs doesn’t work. I would just fetch() the font file and use the returned buffer to supply to jimp
Answer
Chestnut-backed ChickadeeOP
I just gave up on using that library 
