-
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
.envfile 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:9011How do I resolve the error
Error: FUSIONAUTH_ISSUERmissing in environment variables.that was thrown if thoughFUSIONAUTH_ISSUERwas setup and referenced from the .envfile? -
@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)?
-
@jswgger007 Is it possible that you have a
.env.localthat would overwrite the default values in.env?Is this issue happening when you run the app locally or in some other environment?
-
D dan moved this topic from Q&A on
-
D dan moved this topic from Frequently Asked Questions (FAQ) on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login