AWS Amplify Env Variable not picked up

1

Hello,

I am using Amplify to deploy a Next.js 13.4 app using NextAuth. The project runs perfectly on my local environment. NextAuth requires a secret which I put in Amplify's environment variables, but when I deploy the code, I get a server error and the logs say 'NO SECRET'

已提問 1 年前檢視次數 783 次
3 個答案
1

Hi - Our recommendation is to not use environment variables to store secrets. Store secrets in an environment secret created using the AWS Systems Manager Parameter Store.

Reference : https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html

profile pictureAWS
專家
已回答 1 年前
  • Thank you! I moved all of my env variables as you suggested and still get this in the logs:

    INIT_START Runtime Version: nodejs:16.v15 Runtime Version ARN: arn:aws:lambda:us-east-2::runtime:ce158dcc19c42286fef86a8dfb67e1efd92d0de18828736a00f3698410aabcb3 2023-07-14T14:24:47.439-06:00 LOGS Name: bootstrap State: Subscribed Types: [Platform, Function] 2023-07-14T14:24:48.222-06:00 START RequestId: 682f871d-4492-43c8-8b2f-9479064951e7 Version: $LATEST 2023-07-14T14:24:50.270-06:00 [next-auth][error][NO_SECRET] 2023-07-14T14:24:50.270-06:00 https://next-auth.js.org/errors#no_secret Please define a secret in production. MissingSecret [MissingSecretError]: Please define a secret in production. 2023-07-14T14:24:50.270-06:00 at assertConfig (/var/task/.next/server/chunks/294.js:6938:16) 2023-07-14T14:24:50.270-06:00 at AuthHandler (/var/task/.next/server/chunks/294.js:6480:54) 2023-07-14T14:24:50.270-06:00 at processTicksAndRejections (node:internal/process/task_queues:96:5) 2023-07-14T14:24:50.270-06:00 at async NextAuthRouteHandler (/var/task/.next/server/chunks/294.js:9662:30) 2023-07-14T14:24:50.270-06:00 at async NextAuth._args$ (/var/task/.next/server/chunks/294.js:9696:24) 2023-07-14T14:24:50.270-06:00 at async /var/task/.next/server/chunks/981.js:2702:37 { 2023-07-14T14:24:50.270-06:00 code: 'NO_SECRET' 2023-07-14T14:24:50.270-06:00 } 2023-07-14T14:24:50.319-06:00 REPORT RequestId: 682f871d-4492-43c8-8b2f-9479064951e7 Duration: 2096.26 ms Billed Duration: 20

0

Ok, so I was able to log the env variables from Param Store, so that is not the issue. Is this the best forum on AWS to ask about NextAuth?

已回答 1 年前
0

https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#environment-secrets

Access environment secrets Accessing an environment secret during a build is similar to accessing environment variables, except that environment secrets are stored in process.env.secrets as a JSON string.

Make sure to specify the app id and backend app name

George
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南