How To Solve NextAuth Error No Secret In Production
NextAuth
10/11/2022
If you get the following error by NextAuth in production,
ZSH
MissingSecret [MissingSecretError]: Please define a `secret` in production.
it means you are missing a secret that is used for various cryptographic tasks such as signing cookies, creating keys, etc.
By default, one does not need to set a secret in development mode as a hash is automatically generated using the options
object passed into the NextAuth function.
In production, however, you must explicitly set one using the environment variable NEXTAUTH_SECRET
. You can easily generate a secret with the command below.
ZSH
$ openssl rand -base64 32