Skip to content

Issue loading font with Jimp package in API function call #64768

Answered by latentsauce
Bubaflip asked this question in Help
Discussion options

You must be logged in to vote

@Bubaflip have you tried modifying your next.config file like this? i had the same issue and i fixed it by doing:

/** @type {import('next').NextConfig} */

const nextConfig = {
  experimental: {
    outputFileTracingIncludes: {
      "/api/<your-api-route>": ["./assets/**"] // i put my font files in a folder called assets in root
    }
  }
}

export default nextConfig

and in my api route:

import path from "path"
const fontPath = path.resolve("./assets/impact.fnt")
const font = await Jimp.loadFont(fontPath)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@Bubaflip
Comment options

Comment options

You must be logged in to vote
3 replies
@zkMyst
Comment options

@Bubaflip
Comment options

@Justbeingjustin
Comment options

Answer selected by Bubaflip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants