-1

How does GAE (Google App Engine) treat NODE_ENV on deployment and run with a NodeJS runtime?

Google docs clearly states that some variables are automatically set and cannot overridden except the `NODE_ENV. How do you do that?

I have tried setting it in app.yaml and even though it is shown as properly set in the GAE console it is not reflected in the app. I have tried using non-standard value in the app.yaml such as NODE_ENV: foobar and the build process does recognize it but the value that the application reads is always production.

warn - You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env

1 Answer 1

0

Since GAE automatically sets it to "production" in production environments, my take to handle NODE_ENV in Google App Engine (GAE) is to not directly modify NODE_ENV.

You should use custom environment variables to manage your specific configuration needs.

  1. Set a custom environment variable in your app.yaml:
env_variables:
  CUSTOM_NODE_ENV: "foobar"
  1. Access the custom variable in your application:
const customEnv = process.env.CUSTOM_NODE_ENV || 'default_value';
console.log(customEnv);  // where "foobar" should log
Sign up to request clarification or add additional context in comments.

2 Comments

Did this work? Any suggestions or confirmation to my solution would be appreciated.
This will work. In fact I have already implemented it that way. The questions is if someone has some clue as to what is going on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.