Closed nphmuller closed 7 months ago
Current workaround is to just set anything to AUTH_SECRET
during build time and change the env variable again during runtime. But yea this is very annoying.
It is not even reading the secret while using npm next dev, the check for AUTH_SECRET should not be there until the app has been completely initialiazed, that means until the environment variables have been loaded (build time is bad for it also)
Hi all,
Current workaround is to just set anything to AUTH_SECRET during build time
This would be my suggestion too. The reason for this is that some path in your code might be hit during prerendering (next build
) that relies on auth. This will result in the AUTH_SECRET
check invocation.
npx auth secret
for example.It is not even reading the secret while using npm next dev,
This sounds unrelated and something specific to your project. Next.js reads environment variables as a priority so they should always be available before the dev server is initialized. I cannot tell more without seeing your code, but it's most likely nothing to do with Auth.js.
I have the same issue with a turborepo project. AUTH_SECRET is set in an env file and is also included in turbo config.
It doesn't appear to be used. I presume pnpm dev
is using the env.local and the pnpm build
even when run locally is not using .env.local or not finding the value for some reason.
Rolling back to the previous beta version does resolve the issue for now
I don't think the issue is resolved just yet @balazsorban44
Please open a new issue with a minimal reproduction then. Please don't give a full monorepo that takes a lot of time to set up, please strip it down to the bare minimum that still reproduces the issue, if the monorepo setup is even relevant. if it reproduces without one, please provide a simple repo isntead.
Saying that it's not resolved is not actionable.
Environment
System: OS: macOS 14.4 CPU: (10) arm64 Apple M1 Pro Memory: 1.56 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node npm: 10.2.5 - ~/.nvm/versions/node/v20.9.0/bin/npm pnpm: 8.15.4 - ~/Library/pnpm/pnpm bun: 1.0.30 - /opt/homebrew/bin/bun Browsers: Chrome: 123.0.6312.105 Safari: 17.4 npmPackages: next: 14.1.4 => 14.1.4 next-auth: 5.0.0-beta.16 => 5.0.0-beta.16 react: ^18 => 18.2.0
Reproduction URL
https://github.com/LoisDuplain/next-auth-example
Describe the issue
This is a duplicate issue for https://github.com/nextauthjs/next-auth/issues/10432 which, in my understanding, was closed incorrectly.
The linked issue meant that AUTH_SECRET suddenly was required during the build, while it previously was not. It was already clear that AUTH_SECRET (or the secret config option) was required during runtime. But the breaking behaviour is that it now suddenly is required during build.
How to reproduce
npm install
npm run build
The build now fails with the following error:
Expected behavior
No error. The build should succeed.