You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next.js really doesn't want you to do server side functions on your 404 page:
Error: pages/404 can not have getInitialProps/getServerSideProps, https://err.sh/next.js/404-get-initial-props
But sometimes this is preferable. In an ideal world you could add getServerSideProps to do custom 301 redirection and otherwise you can do a Router.push client side.
The behavior I'm looking for is something like:
404.js:
/old/blog -> 301 to /blog
/gone/page -> 404 in this case
/* -> 301 to /
Is there a workaround to doing custom server-side response statuses for SEO reasons?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Next.js really doesn't want you to do server side functions on your 404 page:
Error:
pages/404can not have getInitialProps/getServerSideProps, https://err.sh/next.js/404-get-initial-props
But sometimes this is preferable. In an ideal world you could add getServerSideProps to do custom 301 redirection and otherwise you can do a Router.push client side.
The behavior I'm looking for is something like:
404.js:
Is there a workaround to doing custom server-side response statuses for SEO reasons?
Beta Was this translation helpful? Give feedback.
All reactions