Authentication 下一个SSR私人页面

Authentication 下一个SSR私人页面,authentication,next.js,server-side-rendering,Authentication,Next.js,Server Side Rendering,有谁能帮我回答一个关于下一个SSR和私人路线的问题吗。 我有一个页面,使用getStaticProps由SSR装载,并希望确保只有授权用户才能访问 我尝试了getServerSideProps,但无法将getServerSideProps与getStaticProps一起使用 我还尝试了一些HOCs实现,但是当我的页面被auth hoc组件包装时,我的页面并没有特别的getStaticProps 编辑 页面名为staticProps,但不接收staticProps更新的数据。仅在道具上未定义 帮

有谁能帮我回答一个关于下一个SSR和私人路线的问题吗。 我有一个页面,使用getStaticProps由SSR装载,并希望确保只有授权用户才能访问

我尝试了getServerSideProps,但无法将getServerSideProps与getStaticProps一起使用

我还尝试了一些HOCs实现,但是当我的页面被auth hoc组件包装时,我的页面并没有特别的getStaticProps

编辑 页面名为staticProps,但不接收staticProps更新的数据。仅在道具上未定义

帮忙? 谢谢

我的道具

export const getStaticProps:getStaticProps=async context=>{
const{slug}=context.params;
const response=await api.get(`course/${slug}`);
const course=response.data;
返回{
道具:{
课程
},
重新验证日期:600,
};
};
导出默认privateRoute(课程);
我的孩子


函数redirectToHome(){
路由器。替换(“/”);
}
函数privateRoute(WrappedComponent:any){
返回类扩展组件{
状态:{isLoading:boolean};
建造师(道具){
超级(道具);
此.state={
孤岛加载:是的,
};
}
异步组件didmount():承诺{
如果(!cookies.get(AUTH_TOKEN_COOKIE)){
重定向到home();
}
试一试{
const user=wait AuthService.getUser();
如果(用户?\u id){
const permit=等待permissionService.get(用户id);
如果(!许可证){
重定向到home();
}
}
}捕获(e){
控制台日志(e);
重定向到home();
}
}
render(){
const{isLoading}=this.state;
返回(
{正在加载?检查权限:}
);
}
};
}
导出默认私有路由;

您需要将道具从HOC传递到

render(){
const{isLoading}=this.state;
返回(
{正在加载?检查权限:}
);
}

您确定HOC不会调用
getStaticProps
吗?你们有什么错误吗?它被调用了,但不要在页面上注入staticprops。我的页面只接收未定义的道具。谢谢!!!!!!!!!