We ran into the [next-auth][error][NO_SECRET]
issue, and here's how we resolved it:
NEXTAUTH_SECRET
Environment Variable:NEXTAUTH_SECRET
environment variable was available during both the build and runtime processes. To do this, we added the NEXTAUTH_SECRET
to the env
field inside next.config.js
.module.exports = {
env: {
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
},
};
This made sure that the secret was correctly injected into the app when it was built and when it ran on AWS Amplify.
Set the NEXTAUTH_SECRET
in AWS Amplify:
In AWS Amplify, we navigated to the Backend environments section and correctly set the NEXTAUTH_SECRET
under environment variables. This ensures that the secret is available in the AWS environment as well.
Redeployed the App:
After making these changes, we redeployed the app in Amplify. The redeployment applied the environment variable settings, and the [next-auth][error][NO_SECRET]
issue was successfully resolved.