FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    How to Resolve `Error: FUSIONAUTH_ISSUERmissing in environment variables.`?

    Scheduled Pinned Locked Moved Unsolved
    Q&A
    3
    3
    4.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jswgger007
      last edited by

      Hello all, I ran into an issue, perhaps a bug after following the guide on this page: fusionauth.io/docs/quickstarts/quickstart-javascript-nextjs-web - Running the app I got this error:

      Unhandled Runtime Error
      Error: FUSIONAUTH_ISSUERmissing in environment variables.
       
        10 | const missingError = 'missing in environment variables.';
        11 | if (!fusionAuthIssuer) {
      > 12 | throw Error('FUSIONAUTH_ISSUER' + missingError)
           |      ^
        13 | }
        14 | if (!fusionAuthClientId) {
        15 | throw Error('FUSIONAUTH_CLIENT_ID' + missingError)
      

      I have these code from the guide in my [..nextauth].js file:

      import NextAuth from "next-auth"
      import FusionAuthProvider from "next-auth/providers/fusionauth"
      
      const fusionAuthIssuer = process.env.FUSIONAUTH_ISSUER;
      const fusionAuthClientId = process.env.FUSIONAUTH_CLIENT_ID;
      const fusionAuthClientSecret = process.env.FUSIONAUTH_CLIENT_SECRET;
      const fusionAuthUrl = process.env.FUSIONAUTH_URL;
      const fusionAuthTenantId = process.env.FUSIONAUTH_TENANT_ID;
      
      const missingError = 'missing in environment variables.';
      if (!fusionAuthIssuer) {
          throw Error('FUSIONAUTH_ISSUER' + missingError)
      }
      if (!fusionAuthClientId) {
          throw Error('FUSIONAUTH_CLIENT_ID' + missingError)
      }
      if (!fusionAuthClientSecret) {
          throw Error('FUSIONAUTH_CLIENT_SECRET' + missingError)
      }
      if (!fusionAuthUrl) {
          throw Error('FUSIONAUTH_URL' + missingError)
      }
      if (!fusionAuthTenantId) {
          throw Error('FUSIONAUTH_TENANT_ID' + missingError)
      }
      
      export const authOptions =
      {
          providers: [
              FusionAuthProvider({
                  issuer: fusionAuthIssuer,
                  clientId: fusionAuthClientId,
                  clientSecret: fusionAuthClientSecret,
                  wellKnown: `${fusionAuthUrl}/.well-known/openid-configuration/${fusionAuthTenantId}`,
                  tenantId: fusionAuthTenantId, // Only required if you're using multi-tenancy
              }),
          ],
          pages: {
              signIn: '/login',
              error: '/error',
          },
      }
      
      const handler = NextAuth(authOptions)
      
      export { handler as GET, handler as POST }
      

      and these values setup in my .env file as such:

      #FUSIONAUTH
      # Note - While these are not actual values, gives an idea how they are setup. 
      FUSIONAUTH_CLIENT_ID=277ae50583
      FUSIONAUTH_CLIENT_SECRET=AeJ3phcpmlVEAY
      FUSIONAUTH_URL=http://localhost:9011
      FUSIONAUTH_API_KEY=l06CVWVemOBA13-eX_e
      FUSIONAUTH_TENANT_ID=49427a8a-301d0
      FUSIONAUTH_ISSUER=http://localhost:9011
      

      How do I resolve the error Error: FUSIONAUTH_ISSUERmissing in environment variables. that was thrown if though FUSIONAUTH_ISSUER was setup and referenced from the .env file?

      danD A 2 Replies Last reply Reply Quote 0
      • danD
        dan @jswgger007
        last edited by

        @jswgger007 Hmmm. That's weird.

        What happens if you put console.log(process.env.FUSIONAUTH_ISSUER); right a t the top of the file?

        Seems like the environment variable isn't being picked up for some reason.

        What type of system are you using (windows, mac, linux, etc)?

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • A
          akoskm @jswgger007
          last edited by

          @jswgger007 Is it possible that you have a .env.local that would overwrite the default values in .env?

          Is this issue happening when you run the app locally or in some other environment?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post