Skip to content

URL is considered invalid in experimental_getFontFileURL() when using Cloudflare adapter #17722

Description

@azrdn

Astro Info

Astro                    v7.2.2
Node                     v26.3.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

Not applicable

Describe the Bug

When experimental_getFontFileURL() is used while using the cloudflare adapter, vite errors with:

14:03:33 [ERROR] [vite] Internal server error: The `"/_astro/fonts/font-inter-400-italic-latin-863c6d4ebf55aa09.woff2"` URL passed to the `experimental_getFontFileURL()` function is invalid.
      at getFontFileURL (/home/azrd/Repositories/font_repro/node_modules/.pnpm/astro@7.2.2_@emnapi+core@1.11.1_@emnapi+runtime@1.11.3/node_modules/astro/dist/assets/fonts/core/create-get-font-file-url.js:11:13)
      at Module.GET (/home/azrd/Repositories/font_repro/src/pages/og.png.ts:7:20)
      at renderEndpoint (/home/azrd/Repositories/font_repro/node_modules/.pnpm/astro@7.2.2_@emnapi+core@1.11.1_@emnapi+runtime@1.11.3/node_modules/astro/dist/runtime/server/endpoint.js:37:32)
      at PagesHandler.handle (/home/azrd/Repositories/font_repro/node_modules/.pnpm/astro@7.2.2_@emnapi+core@1.11.1_@emnapi+runtime@1.11.3/node_modules/astro/dist/core/pages/handler.js:23:26)

This was used in a astro endpoint to generate og images (src/pages/og.png.ts), it breaks recently in new Astro version (idk which version)

What's the expected result?

Font url is is generated without errors

Link to Minimal Reproducible Example

https://github.com/azrdn/astro_font_bug

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions