lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

🐛 BUG: Non-HTML pages with spread/rest parameter crashes dev server

Open delucis opened this issue 3 years ago • 1 comments

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.

delucis avatar Jun 21 '22 22:06 delucis

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!

bholmesdev avatar Jun 21 '22 22:06 bholmesdev