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({