Skip to content

SSR Bundle exposes original assets from prerendered pages to _astro #15503

@spaceemotion

Description

@spaceemotion

Astro Info

Astro                    v5.17.2
Vite                     v6.4.1
Node                     v24.13.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/vercel (v9.0.4)
Integrations             none

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

No response

Describe the Bug

When added a route that's either being prerendered on the server, or just does a simple REST API response, the SSR build mode gets enabled. However, this immediately pulls seems to pull in all the assets in the module graph, even for assets that are only used on pages that are statically prerendered.

This causes the final deployment output to balloon, especially on larger sites, and even more so when using large original PNG files (e.g. over 1MB each).

This also exposes all Astro sites that do have SSR enabled to the ability to "guess" the original file name from any Image emitted by the build process:

For example, using the official Astro page:

  1. https://astro.build/_astro/starlight-lp.Cy5G1hqN_ZFOB5U.webp?dpl=698f012b5f244e000861f795 is a screenshot of a website in WEBP
  2. if I remove the extra suffix + change webp to png: https://astro.build/_astro/starlight-lp.Cy5G1hqN.png?dpl=698f012b5f244e000861f795
  3. The original file shows up

What's the expected result?

  • Only the assets required for pages marked as export prerendered = false should be pulled into the final output.
  • None of the original images should show up in the client build output, and only should be accessible to the server build (where it may need them to render the page server-side).

Link to Minimal Reproducible Example

https://github.com/spaceemotion/astro-bug-original-file-exposure-ssr

Participation

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

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions