1

I started with this sample repo: https://github.com/vercel/next.js/tree/canary/examples/auth0

My current repo: https://github.com/rebeccapeltz/next-auth-app-1

Login/Logout work fine locally. When I deploy to Vercel and logout I get this message in the browser:

Invalid character in header content ["Location"]

I've double checked the Auth0 env variables and they seem correct. Login works fine on Vercel. Can't figure out how to troubleshoot the header Location value that is causing the problem.

Nothing much going on yet and easy to reproduce: https://next-auth-app-1.now.sh/

1 Answer 1

1

Solved this by removing all env variables added to the Vercel online application settings. Then added the secrets using the now CLI now secrets add and deployed the app by setting up other env variables in now.json and using now --prod. Working OK now. For further external env secrets and references, I'm wondering if t's better to add them via now.json or to use the online settings GUI. One thing that wasn't clear is that when you add variables with now add secrets you need to prefix the value in the now.json with @. Kind of like accessing bash env variables with $. So after adding secrets my now.json looks like this

{
  "build": {
    "env": {
      "AUTH0_DOMAIN": "<name of auth0 domain>",
      "AUTH0_CLIENT_ID": "<what you get from auth0>",
      "AUTH0_CLIENT_SECRET": "@auth0_client_secret",
      "REDIRECT_URI": "<name of vercel app or domain name>/api/callback",
      "POST_LOGOUT_REDIRECT_URI": "<name of vercel app>/",
      "SESSION_COOKIE_SECRET": "@session_cookie_secret"
    }
  }
}

Should you add all env using secrets add and then just reference by name in the now.json? not sure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.