0

I have an app that works properly on development environment, but once I deploy, the getProviders method which is called at server side returns NULL to my component. If I visit https://MY_URL/api/auth/providers, I get the JSON I'm supposed to receive from getProviders too

Here's the relevant code:

import { useEffect } from "react";
import { getProviders } from "next-auth/react";

const Estabelecimento = ({ abreviatura, providers }: any) => {
  console.log(providers) // logs null
  useEffect(() => {
    console.log(providers); // also logs null
  }, [providers]);


  // rest of code...
}

export async function getServerSideProps(context: any) {
  const abreviatura = context.params.estabelecimento;
  const providers = await getProviders();

  return {
    props: {
      abreviatura: abreviatura,
      providers,
    },
  };
}

export default Estabelecimento;

Gustavo Farias
  • 393
  • 5
  • 15
  • Have you properly configured the `NEXTAUTH_URL` environment variable wherever you're deploying the app to? – juliomalves Jan 07 '22 at 13:26
  • @juliomalves I think I did, it seems to be a problem where Amplify(where I'm deploying) is not settings the ENV variable properly, when deploying to firebase/vercel it works fine. On Amplify, I have the provisory solution of using axios to fetch at https://MY_URL/api/auth/providers at the server side and use it on the client side – Gustavo Farias Jan 07 '22 at 18:13

0 Answers0