Building standalone project does not carry over the .env.local
Answered
Giant ichneumon wasp posted this in #help-forum
Giant ichneumon waspOP
I'm new to next.js and actually just want to help a friend deploy a next.js project. I ran
next build of course to do this, and my understanding is that starting the .next/standalone/server.js file is the correct way to run the production build. Though when I run this, the database uri is undefined and connection fails. I believe the environment variables are not being carried over in the build process, what is the expected behaviour here for a production build?Answered by Giant ichneumon wasp
I removed
output: "standalone" from the config and now starting normally with next start works. Thanks3 Replies
It should work if you’re starting the application with
next start commandOtherwise, use packages like dot-env cli to manually parse environment variables (not recommended since Next.js supports it by default)
@fuma It should work if you’re starting the application with `next start` command
Giant ichneumon waspOP
I removed
output: "standalone" from the config and now starting normally with next start works. ThanksAnswer