From ccfee1c8b5e103551c63c9f65ab526d60e74fd93 Mon Sep 17 00:00:00 2001 From: rzen Date: Sun, 12 Jul 2026 18:47:15 -0400 Subject: [PATCH] site: fix dev-server 404 on scoped feed URLs With trailingSlash 'always', astro dev only matches dynamic-route endpoints when the request has a trailing slash, so the RSS pill links (/tags//rss.xml, /categories//rss.xml) 404'd locally while the built site served them fine. Dev-only vite middleware rewrites those requests to the slashed form. Claude-Session: https://claude.ai/code/session_01WZaczDJjL3xZ3u5spsN5AL --- astro.config.mjs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/astro.config.mjs b/astro.config.mjs index 995d878..f75c442 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -128,11 +128,26 @@ const setPickApi = { }, }; +// With trailingSlash 'always', the dev server only matches dynamic-route +// endpoints (/tags//rss.xml, /categories//rss.xml) when the request +// has a trailing slash; the built site serves them as plain files without +// one. Rewrite in dev so the same URLs work in both. +const feedSlashShim = { + name: 'feed-trailing-slash-dev-shim', + apply: 'serve', + configureServer(server) { + server.middlewares.use((req, res, next) => { + if (/^\/(tags|categories)\/[^/]+\/rss\.xml$/.test(req.url)) req.url += '/'; + next(); + }); + }, +}; + export default defineConfig({ site: 'https://unique.rzen.dev', trailingSlash: 'always', build: { format: 'directory' }, - vite: { plugins: [editFindTagApi, setPickApi] }, + vite: { plugins: [editFindTagApi, setPickApi, feedSlashShim] }, integrations: [ mdx(), sitemap({