Reactjs getServerSideProps上的next.js重定向引发有关道具的错误

Reactjs getServerSideProps上的next.js重定向引发有关道具的错误,reactjs,next.js,Reactjs,Next.js,如果我的表达式失败,我只是尝试从这个页面重定向到另一个页面。我阅读了文档,完全按照他们所做的做了,上网看了看,做了他们所做的,每次我都会得到这些 Error: Additional keys were returned from `getServerSideProps`. Properties intended for your component must be nested under the `props` key, e.g.: return { props: { title:

如果我的表达式失败,我只是尝试从这个页面重定向到另一个页面。我阅读了文档,完全按照他们所做的做了,上网看了看,做了他们所做的,每次我都会得到这些

Error: Additional keys were returned from `getServerSideProps`. Properties intended for your component must be nested under the `props` key, e.g.:

    return { props: { title: 'My Title', content: '...' } }

Keys that need to be moved: redirect.
Read more: https://err.sh/next.js/invalid-getstaticprops-value
This error happened while generating the page. Any console logs will be displayed in the terminal window.
这是我在页面中的代码

export async function getServerSideProps(req) {
  if(req){
    return {
      redirect: {
        permanent: false,
        destination: "/"
      }
    }
  }
}

根据您的代码,您希望随时临时重定向到基本URL。如果是这种情况,那么在
next.config.js

module.exports={
异步重定向(){
返回[
{
来源:“/您的页面”//无论您的页面是什么
目的地:“/”,
永久性:假,
},
]
},
}
参考


我试过了,没用。我正在使用9.5-将尝试升级到10@noobCoder我忘了问版本了。是的,Next.js 10中介绍了
getServerSideProps
上的重定向。