Checks.state argument is missing auth0

I have a next.js auth0 application hosted on netlify. around 70-80% of the time authentication flow works fine but 10-20% of the time are we are getting invalid_grant (Failed to verify code verifier) or checks.state argument is missing .

  • I looked into the previous questions asked here but they were not helpful

Hi @pranshushah

Thanks for contacting Auth0 Community.

Do you have any proxy in front of your app. ? It looks like something is stripping away the state query param which is required for callbacks.

Thanks
Jeff

yes. but they are not related to auth routes.

for example, our auth routes are in /api/auth and we are proxying /api/apis/*

export function getServerSideProps(context: GetServerSidePropsContext) {
  const { req, res } = context;
  const authorizationData = isAuthorizedToApp(req, res);
  if (authorizationData.user) {
    if (!authorizationData.isAuthorized) {
      return {
        redirect: {
          destination: "api/auth/login",
          permanent: false,
        },
      };
    }
    return {
      props: {
        user: authorizationData.user,
      },
    };
  }
  return {
    redirect: {
      destination: "api/auth/login",
      permanent: false,
    },
  };
}

can this be a issue?

https://xyz.com/api/auth/callback?code=EZ3A8J9X_HRDauy47MwxDdyfPxI34BxuJgpJk1msRQpT7&state=eyJyZXR1cm5UbyI6Imh0dHBzOi8vZGV2LmFkbWluLm1ldGFmb2xpby50byJ9


AND I have sent you the config in the private message.