🐛 BUG: Non-HTML pages with spread/rest parameter crashes dev server
What version of astro are you using?
v1.0.0-beta.50
Are you using an SSR adapter? If so, which one?
No
What package manager are you using?
npm
What operating system are you using?
macOS / Stackblitz
Describe the Bug
When creating a dynamic non-HTML (endpoint) route, the dev server crashes if you include the file extension after a spread/rest param (as recommended for non-HTML pages).
For example, src/pages/api/[...path].json.ts would trigger the error: Invalid route — rest parameter must be a standalone segment.
Workaround is to rename to src/pages/api/[...path].ts and return a.json, segment/file.json etc. as your path param in getStaticPaths.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-eaqqq1-efy3y9?file=src/pages/api/[...slug].json.ts
Participation
- [ ] I am willing to submit a pull request for this issue.
Update: can confirm [...spread].json.ts does work in SvelteKit SSR. We borrowed their segment logic, so that gives me hope we can resolve this easily!