Skip to content

Conversation

@Princesseuh
Copy link
Member

Changes

When an image is using @fs, we can fetch it directly through Vite, that way it'll automatically respect Vite's limitations in regard to which files are allowed to be loaded.

Fixes #14957
Fixes #14937

Testing

We had a test for this already, but it didn't fetch the images (mostly because it was about path construction back in the day) so I updated it to actually try to fetch them

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: c7d1a58

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Dec 8, 2025

// Vite allows loading files directly from the filesystem
// as long as they are inside the project root.
if (isParentDirectory(fileURLToPath(root), src)) {
Copy link
Member Author

@Princesseuh Princesseuh Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure exactly what the code below here is trying to cover, because you cannot pass file paths anyway to getImage / Image so the only way you can hit it is by building a path manually, which won't anyway work in prod (well, it could, but then it wouldn't work in dev). I decided to leave it as-is just in case, but in my mind, we could remove it.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #14982 will not alter performance

Comparing fix/image-outside (c7d1a58) with main (ef53716)1

Summary

✅ 6 untouched

Footnotes

  1. No successful run was found on main (00c06ef) during the generation of this report, so ef53716 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me!

@Princesseuh Princesseuh merged commit 6849e38 into main Dec 10, 2025
45 of 47 checks passed
@Princesseuh Princesseuh deleted the fix/image-outside branch December 10, 2025 14:17
This was referenced Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

3 participants