yakovlev-alexey / nest-next-example

Project repo for Nest.js + Next.js tutorial available on dev.to and Habr
https://dev.to/yakovlev_alexey/creating-a-project-with-nestjs-nextjs-3i1i
MIT License
97 stars 15 forks source link

SSG with fallback 'blocking' is not working #1

Closed DmitryKvant closed 3 years ago

DmitryKvant commented 3 years ago
export async function getStaticPaths() {
  return {
    paths: [],
    fallback: 'blocking'
  }
}

export const getStaticProps = wrapper.getStaticProps(store => async (ctx) => {
  console.log(ctx.params)

  return{
    revalidate: 1,
    props: {}
  }
});

if I run server by yarn start:next, code upper return url params in console, but if I run server by yarn start:dev then i get nothing - empty objects of params

More about SSG - here

DmitryKvant commented 3 years ago

Алексей, любая помощь?

DmitryKvant commented 3 years ago

You used in your examples that:

 @Get('/:id')
 @Render('[id]')
 @UseInterceptors(ParamsInterceptor, ConfigInterceptor)
 page() {
    return {};
 }

Solution is

@Get(':id')
page(@Param('id') id:any,@Res() res: RenderableResponse) {
    res.render(id, {query: 'is not work'});
}