Fix public files taking priority over API routes in build#15331
Fix public files taking priority over API routes in build#15331
Conversation
🦋 Changeset detectedLatest 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 |
|
| 📦 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
delucis
left a comment
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
I'm not sure if this should be a warning or an error, but happy either way personally.
Changes
checkPublicConflict()function ingenerate.tsthat skips writing generated routes when a public file with the same name existsFixes #15165
Testing
astro-public.test.jspublic/robots.txtandsrc/pages/robots.txt.tsDocs
No docs needed - this fixes a bug to match existing documented behavior.