Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning notFound: false from getServerSideProps results in 404 #22472

Closed
ambrauer opened this issue Feb 23, 2021 · 2 comments
Closed

Returning notFound: false from getServerSideProps results in 404 #22472

ambrauer opened this issue Feb 23, 2021 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@ambrauer
Copy link

What version of Next.js are you using?

10.0.3

What version of Node.js are you using?

14.7.0

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next dev

Describe the Bug

When returning notFound: false from getServerSideProps, the 404 status and page are returned, as if notFound: true was returned.

This does not occur when returning notFound: false from getStaticProps.

The obvious workaround is to only set notFound if true, but it's convenient to be able to pass along a variable to notFound, regardless of value. For example:

export const getServerSideProps: GetServerSideProps = async (context) => {
  const props = await pagePropsFactory.create(context);

  return {
    props,
    notFound: props.notFound
  };
};

Additionally, the behavior should be consistent with getStaticProps.

Expected Behavior

Returning notFound: false from getServerSideProps should not result in a 404 status and page. It should render the page as expected (like returning notFound: false from getStaticProps).

To Reproduce

Return notFound: false from a page with getServerSideProps.

export async function getServerSideProps(context) {
  return {
    props: {},
    notFound: false
  }
}

The resulting page will always result in a 404.

@ambrauer ambrauer added the bug Issue was opened via the bug report template. label Feb 23, 2021
@ambrauer ambrauer changed the title Return notFound: false from getServerSideProps results in 404 Returning notFound: false from getServerSideProps results in 404 Feb 23, 2021
@ambrauer
Copy link
Author

Way ahead of me :) I see this will be resolved in the next release. Closing issue.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants