/api/auth/login Lambda@Edge failing with "secret" is required on AWS Amplify

1

I am deploying next.js application with auth0 authentication onto AWS Amplify. This is working on localhost as expected. I created "Environment variables" with AUTH0_SECRET and others in the amplify App Settings, and I am able to authenticate and it is working fine. Suddenly after one of the deployment, I keep getting this error. I redeployed older version, error did not disappear.

I believe it is not the app issue, it is something to do with Amplify settings as previous deployment also stopped working.

Browser Error

503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Logs:


ERROR	Invoke Error 	
{
    "errorType": "TypeError",
    "errorMessage": "\"secret\" is required",
    "stack": [
        "TypeError: \"secret\" is required",
        "    at Object.get (/var/task/node_modules/@auth0/nextjs-auth0/dist/auth0-session/get-config.js:147:15)",
        "    at Object.getConfig (/var/task/node_modules/@auth0/nextjs-auth0/dist/config.js:66:38)",
        "    at Object.initAuth0 (/var/task/node_modules/@auth0/nextjs-auth0/dist/index.js:22:23)",
        "    at getInstance (/var/task/node_modules/@auth0/nextjs-auth0/dist/index.js:18:24)",
        "    at handleAuth (/var/task/node_modules/@auth0/nextjs-auth0/dist/index.js:124:18)",
        "    at Object.5862 (/var/task/pages/api/auth/[...auth0].js:214:129)",
        "    at __webpack_require__ (/var/task/webpack-api-runtime.js:25:42)",
        "    at Object.7416 (/var/task/pages/api/auth/[...auth0].js:189:23)",
        "    at __webpack_require__ (/var/task/webpack-api-runtime.js:25:42)",
        "    at __webpack_exec__ (/var/task/pages/api/auth/[...auth0].js:325:39)"
    ]
}

for debugging, I printed the secret using console.log and I am able to see it.

Reproduction my [...auth0].js

import { handleAuth } from '@auth0/nextjs-auth0';
console.log('the AUTH0_SECRET env var is set: ', !!process.env.AUTH0_SECRET);
export default handleAuth();

Environment Please provide the following:

Version of this library used: "@auth0/auth0-react": "^1.9.0", "@auth0/nextjs-auth0": "^1.7.0", "axios": "^0.26.1", "jsonwebtoken": "^8.5.1", "next": "latest", "react": "17.0.2", "react-dom": "17.0.2", "react-is": "^18.0.0", "swr": "^1.3.0",

  • Did you ever find a workaround?

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인