2020-09-08 09:23:21 +02:00
|
|
|
# Invalid Redirect getStaticProps/getServerSideProps
|
|
|
|
|
|
|
|
#### Why This Error Occurred
|
|
|
|
|
|
|
|
The `redirect` value returned from your `getStaticProps` or `getServerSideProps` function had invalid values.
|
|
|
|
|
|
|
|
#### Possible Ways to Fix It
|
|
|
|
|
|
|
|
Make sure you return the proper values for the `redirect` value.
|
|
|
|
|
|
|
|
```js
|
|
|
|
export const getStaticProps = ({ params }) => {
|
|
|
|
if (params.slug === 'deleted-post') {
|
|
|
|
return {
|
|
|
|
redirect: {
|
2020-11-01 04:37:06 +01:00
|
|
|
permanent: true, // or false
|
|
|
|
destination: '/some-location',
|
|
|
|
},
|
2020-09-08 09:23:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
// data
|
2020-11-01 04:37:06 +01:00
|
|
|
},
|
2020-09-08 09:23:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Useful Links
|
|
|
|
|
|
|
|
- [Data Fetching Documentation](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation)
|