question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`/api/auth/login` failing with "secret" is required on AWS Amplify

See original GitHub issue

Description

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

Browser Error

503 ERROR
The request could not be satisfied.

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",

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
alexboulaycommented, Oct 19, 2022

@ilarumk I am having the same issue. It feels weird having to write a script that will create a .env file when the vars can be logged and are visible…makes no sense.

do you think it’s a problem with Amplify?

0reactions
noanflahertycommented, Dec 19, 2022

@axelmukwena after much trial and error, I stumbled upon these AWS help docs which helped a lot.

Specifically, going to the “Build settings” page of my app and updating the build section to:

        build:
          commands:
            - env | grep -e AUTH0_ >> .env.production
            - npm run build
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Amplify identity and access
Use the following information to help you diagnose and fix common issues that you might encounter when working with Amplify and IAM. If...
Read more >
Allow AWS Amplify access a restricted site for npm builds
Setup I am using AWS Amplify to host my NextJS app. ... asked 7 months ago. /api/auth/login Lambda@Edge failing with "secret" is required...
Read more >
Functions - Access secret values - AWS Amplify Docs
Each Amplify environment can have a different secret value. This enables use cases such as different API keys for a dev and prod...
Read more >
AWS Amplify deployments failing - node.js - Stack Overflow
I'm trying to update my AWS Amplify app and I get this error, I have no idea what's wrong, everything works just fine...
Read more >
Amplify vs amazon-cognito-identity-js vs AWS SDK
Will you need to use secret-enabled app client in Cognito? Are you going to call Cognito APIs that require AWS developer credentials?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found