Skip to content

Fix public files taking priority over API routes in build#15331

Merged
matthewp merged 1 commit intonextfrom
fix/public-files-priority
Jan 29, 2026
Merged

Fix public files taking priority over API routes in build#15331
matthewp merged 1 commit intonextfrom
fix/public-files-priority

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

Changes

  • Fixes an issue where API routes would overwrite public files during build
  • Public files now correctly take priority over generated routes in both dev and build modes
  • Added checkPublicConflict() function in generate.ts that skips writing generated routes when a public file with the same name exists

Fixes #15165

Testing

  • Added tests for both dev and build modes in astro-public.test.js
  • Added test fixtures: public/robots.txt and src/pages/robots.txt.ts

Docs

No docs needed - this fixes a bug to match existing documented behavior.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 3aabdfa

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 Jan 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Package Trust Level Decreased

Caution

Decreased trust levels may indicate a higher risk of supply chain attacks. Please review these changes carefully.

📦 Package 🔒 Before 🔓 After
eslint-plugin-regexp trusted-with-provenance none
@cloudflare/kv-asset-handler trusted-with-provenance none
@cloudflare/unenv-preset trusted-with-provenance none
workerd trusted-with-provenance none
@sveltejs/vite-plugin-svelte-inspector trusted-with-provenance provenance
@sveltejs/vite-plugin-svelte trusted-with-provenance provenance
jsdoc-type-pratt-parser trusted-with-provenance none
miniflare trusted-with-provenance none
youch provenance none
@cloudflare/workerd-darwin-64 trusted-with-provenance none
@cloudflare/workerd-darwin-arm64 trusted-with-provenance none
@cloudflare/workerd-linux-64 trusted-with-provenance none
@cloudflare/workerd-linux-arm64 trusted-with-provenance none
@cloudflare/workerd-windows-64 trusted-with-provenance none
wrangler trusted-with-provenance none

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 28, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing fix/public-files-priority (3aabdfa) with next (0a9777e)2

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on next (cdb99c8) during the generation of this report, so 0a9777e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
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.

Approving conceptually! Makes sense to me that public files should win in this case.

const relativePath = outFilePath.slice(outRoot.length);
const publicFilePath = new URL(relativePath, settings.config.publicDir);
if (fs.existsSync(publicFilePath)) {
logger.warn(
Copy link
Copy Markdown
Member

@Princesseuh Princesseuh Jan 29, 2026

Choose a reason for hiding this comment

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

I'm not sure if this should be a warning or an error, but happy either way personally.

@matthewp matthewp merged commit 4592be5 into next Jan 29, 2026
27 checks passed
@matthewp matthewp deleted the fix/public-files-priority branch January 29, 2026 14:59
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

Development

Successfully merging this pull request may close these issues.

3 participants