What version of astro are you using?
1.3.0
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
Describe the Bug
Custom endpoints/API Routes support getStaticPaths for dynamic routing in static mode. The params in each route can be accessed using the params property of APIContext, but there is no way to access the props returned from getStaticPaths.
The fix would expose props on APIContext.
// src/pages/[id].json.ts
import type { APIRoute } from 'astro';
export const get: APIRoute = async ({ params, request, props }) => {
const id = params.id;
console.log(props); //undefined
return ...
};
export function getStaticPaths() {
return [
{ params: { id: '0' }, props: { name: 'Sarah' } },
{ params: { id: '1' }, props: { name: 'Chris' } },
{ params: { id: '2' }, props: { name: 'Fuzzy' } },
];
}
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-e6xf7j?file=src%2Fpages%2F[id].json.ts%3AL8&on=stackblitz
Participation
What version of
astroare you using?1.3.0
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
Describe the Bug
Custom endpoints/API Routes support
getStaticPathsfor dynamic routing in static mode. Theparamsin each route can be accessed using theparamsproperty ofAPIContext, but there is no way to access thepropsreturned fromgetStaticPaths.The fix would expose
propsonAPIContext.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-e6xf7j?file=src%2Fpages%2F[id].json.ts%3AL8&on=stackblitz
Participation