Search code examples
next.jsauth0

Auth0 Next.js error withPageAuthRequired You should not access 'res' after getServerSideProps resolves


I seem to be getting the error:

You should not access 'res' after getServerSideProps resolves.

With the following code:

export const getServerSideProps = withPageAuthRequired({
  async getServerSideProps(ctx){
    // access the user session
    const session = getSession(ctx.req,ctx.res);
    return {props:{
      customProp:'bar'
    }};
   }
});

This code comes directly from https://auth0.github.io/nextjs-auth0/modules/helpers_with_page_auth_required.html#withpageauthrequiredoptions

I didn't know if there was a way to get rid of this warning when implementing auth0 I'm on Next.js 12.0.4 & auth0 ^1.6.1

What would be the best way to get rid of this error?


Solution

  • It's not an error, it's a warning

    This warning is decribed here, no simple solution

    P.S. I have the same stuff in my projects, waiting for update fix. This bug appeared in next^12.0.2 version