https://www.nextjs.cn/docs/basic-features/data-fetching#getserversideprops-server-side-rendering
export async function getServerSideProps() {
const db = await prepareConnection();
const articles = await db.getRepository(Article).find({
relations: ['user', 'tags'],
});
const tags = await db.getRepository(Tag).find({
relations: ['users'],
});
return {
props: {
articles: JSON.parse(JSON.stringify(articles)) || [],
tags: JSON.parse(JSON.stringify(tags)) || [],
},
};
}