I have some configuration in the .env.local file and i build the next app using 'npm run build' and start the app using 'next start' . Now I change some configuration in the .env.local file and restart the app without rebuilding . This is not picking my updated env file .Can I get some help here. #41555
Replies: 2 comments
-
Env variables are evaluated in build time. To see your updated env vars, you have to rebuild your app. See: https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables |
Beta Was this translation helpful? Give feedback.
-
Hi, This should work... for things that are not optimized/inlined at build-time that is. For example if I use export const getServerSideProps = () => {
console.log(process.env.DB_URL);
return { props: { foo: "bar" } };
}; When build and run, I can change DB_URL through .env files or any other way. However if I had used This is a very vanilla example, and this issue usually appears in non-obvious ways. How are these variables being used? |
Beta Was this translation helpful? Give feedback.
-
KEYCLOAK_ISSUER=http://localhost:8080/realms/new-app
KEYCLOAK_REALM_NAME=new-app
KEYCLOAK_ROLE_APPROVERS=approvers
KEYCLOAK_ROLE_OWNERS=owners
KEYCLOAK_BASE_URL=http://localhost:8080
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=anyth;
Beta Was this translation helpful? Give feedback.
All reactions