Skip to content

fix: Cannot use local font when zeroRuntime is enabledΒ #400

@rishubil

Description

@rishubil

πŸ› The bug

Local fonts were working normally until I configured zeroRuntime, but after enabling zeroRuntime, an error occurs.

Since local fonts don't work properly on StackBlitz, I created a separate repository for reproduction.
https://github.com/rishubil/nuxt-og-image-temp
In this repository, you can confirm that npm run cleanup && npm run build fails when the zeroRuntime setting is enabled.
When the zeroRuntime setting is disabled, it builds successfully.

πŸ› οΈ To reproduce

https://github.com/rishubil/nuxt-og-image-temp

🌈 Expected behavior

It should build normally with local fonts regardless of the zeroRuntime setting.

ℹ️ Additional context

$ npm run cleanup && npm run build

> cleanup
> nuxt cleanup

β„Ή Cleaning up generated Nuxt files and caches...              nuxi 11:10:16 PM

> build
> nuxt build

Nuxt 4.2.1 (with Nitro 2.12.9, Vite 7.2.4 and Vue 3.5.24)      nuxi 11:10:16 PM
β„Ή Building for Nitro preset: node-server                      nuxi 11:10:17 PM
β„Ή Building client...                                               11:10:18 PM
β„Ή vite v7.2.4 building client environment for production...        11:10:18 PM
β„Ή βœ“ 129 modules transformed.                                       11:10:19 PM
[11:10:19 PM] β„Ή ../.nuxt/dist/client/manifest.json                   1.25 kB β”‚ gzip:  0.34 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/error-500.DLkAwcfL.css    1.91 kB β”‚ gzip:  0.73 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/error-404.BLrjNXsr.css    2.43 kB β”‚ gzip:  0.86 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/Bmf3DKhs.js               0.41 kB β”‚ gzip:  0.29 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/KjcP6LMg.js               3.50 kB β”‚ gzip:  1.56 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/BoGLvJ4G.js               9.31 kB β”‚ gzip:  3.74 kB
[11:10:19 PM] β„Ή ../.nuxt/dist/client/_nuxt/CrhI8uPU.js             124.32 kB β”‚ gzip: 47.72 kB
β„Ή βœ“ built in 850ms                                                 11:10:19 PM
βœ” Client built in 861ms                                            11:10:19 PM
β„Ή Building server...                                               11:10:19 PM
β„Ή vite v7.2.4 building ssr environment for production...           11:10:19 PM
β„Ή βœ“ 90 modules transformed.                                        11:10:19 PM
β„Ή βœ“ built in 296ms                                                 11:10:19 PM
βœ” Server built in 303ms                                            11:10:19 PM
β„Ή Initializing prerenderer                                   nitro 11:10:19 PM
β„Ή Prerendering 1 initial routes with crawler                                                                                                                  nitro 11:10:20 PM
  β”œβ”€ / (17ms)                                                                                                                                                  nitro 11:10:20 PM
  β”œβ”€ /_payload.json?5b896f27-4a93-4773-ab37-dbf05a094fe8 (73ms) (skipped)                                                                                      nitro 11:10:20 PM
  β”œβ”€ /_payload.json (74ms)                                                                                                                                     nitro 11:10:20 PM

[11:10:20 PM]  ERROR  [request error] [unhandled] [GET] http://localhost/__og-image__/font/NanumMyeongjo/400.ttf?font=%7B%22cacheKey%22:%22NanumMyeongjo:undefined:400%22,%22style%22:%22normal%22,%22weight%22:400,%22name%22:%22NanumMyeongjo%22,%22key%22:%22nuxt-og-image:fonts:NanumMyeongjo-normal-400.woff.base64%22%7D
 [GET] "https://fonts.googleapis.com/css2?family=NanumMyeongjo:wght@400": 400 Bad Request

    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
    at async fontEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:227:15)
    at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/font/font.mjs:38:12)
    at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
    at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
    at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
    at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
    at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:274:26)
    at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
    at async loadFont (.nuxt/prerender/chunks/_/emojis.mjs:26:12)
    at async Promise.all (index 0)
    at async resolveFonts (.nuxt/prerender/chunks/_/renderer.mjs:442:24)
    at async Promise.all (index 2)
    at async createSvg (.nuxt/prerender/chunks/_/renderer.mjs:450:35)
    at async createPng (.nuxt/prerender/chunks/_/renderer.mjs:469:15)
    at async imageEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:319:13)
    at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/image/image.mjs:38:12)
    at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
    at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
    at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
    at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
    at async generateRoute (node_modules/nitropack/dist/core/index.mjs:2104:17)
    at async Promise.all (index 1)
    at async Promise.all (index 0)
    at async runParallel (node_modules/nitropack/dist/core/index.mjs:1547:3)
    at async prerender (node_modules/nitropack/dist/core/index.mjs:2192:3)
    at async node_modules/@nuxt/nitro-server/dist/index.mjs:774:5
    at async build (node_modules/nuxt/dist/index.mjs:6790:3)
    at async Object.run (node_modules/@nuxt/cli/dist/build-CVr-ruAe.mjs:67:3)
    at async runCommand (node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (node_modules/citty/dist/index.mjs:307:11)
    at async runMain (node_modules/citty/dist/index.mjs:445:7)

  [cause]: [GET] "https://fonts.googleapis.com/css2?family=NanumMyeongjo:wght@400": 400 Bad Request

      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
      at async fontEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:227:15)
      at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/font/font.mjs:38:12)
      at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
      at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
      at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
      at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
      at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:274:26)
      at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
      at async loadFont (.nuxt/prerender/chunks/_/emojis.mjs:26:12)
      at async Promise.all (index 0)
      at async resolveFonts (.nuxt/prerender/chunks/_/renderer.mjs:442:24)
      at async Promise.all (index 2)
      at async createSvg (.nuxt/prerender/chunks/_/renderer.mjs:450:35)
      at async createPng (.nuxt/prerender/chunks/_/renderer.mjs:469:15)
      at async imageEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:319:13)
      at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/image/image.mjs:38:12)
      at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
      at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
      at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
      at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
      at async generateRoute (node_modules/nitropack/dist/core/index.mjs:2104:17)
      at async Promise.all (index 1)
      at async Promise.all (index 0)
      at async runParallel (node_modules/nitropack/dist/core/index.mjs:1547:3)
      at async prerender (node_modules/nitropack/dist/core/index.mjs:2192:3)
      at async node_modules/@nuxt/nitro-server/dist/index.mjs:774:5
      at async build (node_modules/nuxt/dist/index.mjs:6790:3)
      at async Object.run (node_modules/@nuxt/cli/dist/build-CVr-ruAe.mjs:67:3)
      at async runCommand (node_modules/citty/dist/index.mjs:316:16)
      at async runCommand (node_modules/citty/dist/index.mjs:307:11)
      at async runMain (node_modules/citty/dist/index.mjs:445:7)


 ERROR  [request error] [unhandled] [GET] http://localhost/__og-image__/static/og.png                                                                                11:10:20 PM
 [GET] "/__og-image__/font/NanumMyeongjo/400.ttf?font=%7B%22cacheKey%22:%22NanumMyeongjo:undefined:400%22,%22style%22:%22normal%22,%22weight%22:400,%22name%22:%22NanumMyeongjo%22,%22key%22:%22nuxt-og-image:fonts:NanumMyeongjo-normal-400.woff.base64%22%7D": 400 Bad Request

    at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
    at async loadFont (.nuxt/prerender/chunks/_/emojis.mjs:26:12)
    at async Promise.all (index 0)
    at async resolveFonts (.nuxt/prerender/chunks/_/renderer.mjs:442:24)
    at async Promise.all (index 2)
    at async createSvg (.nuxt/prerender/chunks/_/renderer.mjs:450:35)
    at async createPng (.nuxt/prerender/chunks/_/renderer.mjs:469:15)
    at async imageEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:319:13)
    at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/image/image.mjs:38:12)
    at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
    at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
    at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
    at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
    at async generateRoute (node_modules/nitropack/dist/core/index.mjs:2104:17)
    at async Promise.all (index 1)
    at async Promise.all (index 0)
    at async runParallel (node_modules/nitropack/dist/core/index.mjs:1547:3)
    at async prerender (node_modules/nitropack/dist/core/index.mjs:2192:3)
    at async node_modules/@nuxt/nitro-server/dist/index.mjs:774:5
    at async build (node_modules/nuxt/dist/index.mjs:6790:3)
    at async Object.run (node_modules/@nuxt/cli/dist/build-CVr-ruAe.mjs:67:3)
    at async runCommand (node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (node_modules/citty/dist/index.mjs:307:11)
    at async runMain (node_modules/citty/dist/index.mjs:445:7)

  [cause]: [GET] "/__og-image__/font/NanumMyeongjo/400.ttf?font=%7B%22cacheKey%22:%22NanumMyeongjo:undefined:400%22,%22style%22:%22normal%22,%22weight%22:400,%22name%22:%22NanumMyeongjo%22,%22key%22:%22nuxt-og-image:fonts:NanumMyeongjo-normal-400.woff.base64%22%7D": 400 Bad Request

      at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
      at async loadFont (.nuxt/prerender/chunks/_/emojis.mjs:26:12)
      at async Promise.all (index 0)
      at async resolveFonts (.nuxt/prerender/chunks/_/renderer.mjs:442:24)
      at async Promise.all (index 2)
      at async createSvg (.nuxt/prerender/chunks/_/renderer.mjs:450:35)
      at async createPng (.nuxt/prerender/chunks/_/renderer.mjs:469:15)
      at async imageEventHandler (.nuxt/prerender/chunks/_/eventHandlers.mjs:319:13)
      at async Object.handler (.nuxt/prerender/chunks/routes/__og-image__/image/image.mjs:38:12)
      at async Object.handler (node_modules/h3/dist/index.mjs:2004:19)
      at async toNodeHandle (node_modules/h3/dist/index.mjs:2296:7)
      at async b (node_modules/node-mock-http/dist/index.mjs:1:6876)
      at async C (node_modules/node-mock-http/dist/index.mjs:1:7159)
      at async generateRoute (node_modules/nitropack/dist/core/index.mjs:2104:17)
      at async Promise.all (index 1)
      at async Promise.all (index 0)
      at async runParallel (node_modules/nitropack/dist/core/index.mjs:1547:3)
      at async prerender (node_modules/nitropack/dist/core/index.mjs:2192:3)
      at async node_modules/@nuxt/nitro-server/dist/index.mjs:774:5
      at async build (node_modules/nuxt/dist/index.mjs:6790:3)
      at async Object.run (node_modules/@nuxt/cli/dist/build-CVr-ruAe.mjs:67:3)
      at async runCommand (node_modules/citty/dist/index.mjs:316:16)
      at async runCommand (node_modules/citty/dist/index.mjs:307:11)
      at async runMain (node_modules/citty/dist/index.mjs:445:7)

  β”œβ”€ /__og-image__/static/og.png (251ms)                                                                                                                       nitro 11:10:20 PM
  β”‚ β”œβ”€β”€ [400] Bad Request
  β”‚ └── Linked from /
                                                                                                                                                               nitro 11:10:20 PM
Errors prerendering:
  β”œβ”€ /__og-image__/static/og.png (251ms)                                                                                                                       nitro 11:10:20 PM
  β”‚ β”œβ”€β”€ [400] Bad Request
  β”‚ └── Linked from /
                                                                                                                                                               nitro 11:10:20 PM

 ERROR  Exiting due to prerender errors.                                                                                                                             11:10:20 PM

    at prerender (node_modules/nitropack/dist/core/index.mjs:2210:11)
    at async node_modules/@nuxt/nitro-server/dist/index.mjs:774:5
    at async build (node_modules/nuxt/dist/index.mjs:6790:3)
    at async Object.run (node_modules/@nuxt/cli/dist/build-CVr-ruAe.mjs:67:3)
    at async runCommand (node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (node_modules/citty/dist/index.mjs:307:11)
    at async runMain (node_modules/citty/dist/index.mjs:445:7) 



 ERROR  Exiting due to prerender errors. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions