Next.js Discord

Discord Forum

Invalid environment variables

Unanswered
Spot-billed Duck posted this in #help-forum
Open in Discord
Spot-billed DuckOP
Hi guys, I have some issue with env variables:
    GOOGLE_CLIENT_ID: z.string().min(1),
    GOOGLE_CLIENT_SECRET: z.string().min(1),
  },

  /**
   * Specify your client-side environment variables schema here. This way you can ensure the app
   * isn't built with invalid env vars. To expose them to the client, prefix them with
   * `NEXT_PUBLIC_`.
   */
  client: {
    // NEXT_PUBLIC_CLIENTVAR: z.string().min(1),
  },

  /**
   * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
   * middlewares) or client-side so we need to destruct manually.
   */
  runtimeEnv: {
    DATABASE_URL: process.env.DATABASE_URL,
    NODE_ENV: process.env.NODE_ENV,
    NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
    NEXTAUTH_URL: process.env.NEXTAUTH_URL,
    DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
    DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
    GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
    GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
  },

It says:
:x: Invalid environment variables: {
  GOOGLE_CLIENT_ID: [ 'Required' ],
  GOOGLE_CLIENT_SECRET: [ 'Required' ]
}


but in my .env, variables are set

7 Replies

Sloth bear
How did you come up with this problem!? We’re you trying to run a build!?

Make sure that the .env file is in the root

Also verify variable names

You can also try restarting your server

If you’re deploying your app to Vercel or another hosting platform, check the platform’s documentation for any specific requirements or settings related to environment variables. Sometimes, you may need to configure environment variables within the hosting platform

Ensure that the values for GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are strings in your .env file, like this:

ie;
GOOGLE_CLIENT_ID=myClientId
GOOGLE_CLIENT_SECRET=myClientSecret

Check for typos, capitalization, and case sensitivity. Environment variable names are usually case-sensitive, so make sure they match exactly.

.If you have separate environment files (e.g., .env.local, .env.development) for different environments, ensure that you’re using the correct file for your current development environment.
Spot-billed DuckOP
i'm dumb af
GOOGLE_CLIENT_ID:"987XXXXXXXXent.com"
GOOGLE_CLIENT_SECRET:"GOXXXXX7df0"
instead of "="
@Spot-billed Duck GOOGLE_CLIENT_ID:"987XXXXXXXXent.com" GOOGLE_CLIENT_SECRET:"GOXXXXX7df0"
Sloth bear
Yah try rebuilding to see if the error goes away…