Skip to content

base config: static assets + prerendered pages are output without the base prefix when using @astrojs/cloudflare #16276

@Calvin-LL

Description

@Calvin-LL

Astro Info

Astro                    v6.1.5
Vite                     v7.3.2
Node                     v24.14.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare (v13.1.8)
Integrations             none

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

No response

Describe the Bug

When I set base: "/example" in astro.config.mjs and build with @astrojs/cloudflare, the static asset files on disk are still placed at dist/client/* without the base prefix (e.g. dist/client/favicon.ico, dist/client/logos/index.html, dist/client/_astro/foo.woff2).

When the worker is deployed, the Cloudflare Workers static assets binding (env.ASSETS) matches requested URLs literally against the on-disk layout:

  • GET /example/favicon.ico → looks up dist/client/example/favicon.ico404
  • GET /favicon.ico → serves dist/client/favicon.ico (even though no HTML references this path)
  • GET /example/logos/ → looks up dist/client/example/logos/index.html404 (it's at dist/client/logos/index.html)

SSR routes still work because the Astro server entry strips the base before internal routing, but everything prerendered or served as a static asset 404s.

What's the expected result?

With base: "/example" and output: "server" on @astrojs/cloudflare, the build output should be organized so that the URLs Astro wrote into the HTML actually resolve. Concretely: everything currently emitted to dist/client/* should be emitted to dist/client/example/* (keeping dist/client/.assetsignore at the root since wrangler reads it from there).

After such a change, a request to /example/favicon.ico would find dist/client/example/favicon.ico, matching what the generated HTML references.

Link to Minimal Reproducible Example

https://github.com/Calvin-LL/astro-issue

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: cloudflareRelated to the Cloudflare adapter

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions