-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing local font in edge runtime is broken since Next 15 with pages router (vercel/og example) #74385
Comments
There's an issue with the current approach for handling the font files. Filesystem ChangesCode changesHere's the suggested code modification: // /api/og.js
const fontData = await fetch(
new URL(
"./og/lexend-deca-v21-latin_latin-ext-700.ttf",
req.url.substring(0, req.url.lastIndexOf("/api"))
)
).then(res => res.arrayBuffer()); |
just encountered same bug. seems to be something to do with windows and how it builds the file path. strangely it wasn't happening with node 22.10.0 and started when i needed to change to 23.8.0 |
@silence48 |
Yeah something to do with the file url. OG Image Generated Successfully The reason i tried 23.8.0 is because on 22.10.0 i am getting a different error but not saying anything with fonts, it instead says something about source map support lol. I actually literally just gave up and switched to pupateer |
Getting the same issue as silence.
And the line where it throws is this: |
Downgrading node to 20.18.0 instead of 20.18.3 resolved it for me. |
### What We discoved an issue that fetch new URL with static assets in Pages API on edge runtime were failing. Located the issue was an introduced in #66534 where we changed the layer of Pages API with edge runtime entries into API layer, where it actually should be another separate layer like middleware. The quick fix is using middleware bundle layer for Pages API edge functions, but middleware is server-only layer which Pages API is not yet, since it doesn't bundle everything and picking up the `react-server` condition. So we have to create a new layer `apiEdge` to minimize the behavior changes and also fix the bug. The test suite was disabled due to node-fetch blocker, but we now we can enable it. Closes NDX-941 Fixes #74385 [slack-ref](https://vercel.slack.com/archives/C07CGAA2RS6/p1740868643335099)
Link to the code that reproduces this issue
https://github.com/chemicalkosek/og-reproduction
To Reproduce
npm run dev
Current vs. Expected behavior
Current behavior: Og generation fails with a fetch error while importing local file
Expected behavior: It should generate og with custom font. This is working with Next 14
I didn't see any breaking changes in Next 15 that could cause this.
The code also comes from the official example: https://vercel.com/guides/using-custom-font
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 Available memory (MB): 27914 Available CPU cores: 16 Binaries: Node: 22.12.0 npm: 10.9.0 Yarn: N/A pnpm: N/A Relevant Packages: next: 15.1.1-canary.23 // Latest available version is detected (15.1.1-canary.23). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Pages Router, Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: