如果我的表达失败,我只是想从这个页面重定向到另一个页面。我阅读了文档,完全按照他们所做的去做,在网上查看了他们所做的事情,而且我每次都得到这个。
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: "/"
}
}
}
}
答案 0 :(得分:0)
根据您的代码,您希望一直临时重定向到基本 URL。如果是这种情况,那么在 module.exports = {
async redirects() {
return [
{
source: '/your-page', // whatever your page is
destination: '/',
permanent: false,
},
]
},
}
BatchDataset
参考
https://nextjs.org/docs/api-reference/next.config.js/redirects