-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEXTAUTH_URL environment variable not picked up in runtime #3483
Comments
Hi @olemaiwald 👋🏽 thanks for raising this question. To access your environment variables at runtime, you'll need to echo them into your The Next.js server component doesn't have access to environment variables by default to protect any secrets stored as environment variables that are being accessed during the build phase. You can update your amplify.yml to echo the desired environment variables into a Here is an example of how you can accomplish this:
|
Hi @hloriii, thank you for your answer. This has worked for our Amplify application! We have experienced the same issue when deploying our NextJS App as a Docker container on ECS. |
@olemaiwald it should be the same process on ECS (although I'm most familiar with Amplify's services). But you should be able to add those variables to the |
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Before opening, please confirm:
App Id
d3v2fml5415wm2
AWS Region
eu-central-1
Amplify Hosting feature
Frontend builds
Describe the bug
When deploying my Next JS application, I want to set an environment variable NEXTAUTH_URL.
I have set the variable via the environment variables tab in the Amplify console.
This variable also gets picked up in the build step, as I have verified with an echo $NEXTAUTH_URL in the amplify.yml file.
However, when looking at the hosting compute logs, I find the following lines
[next-auth][warn][NEXTAUTH_URL]
https://next-auth.js.org/warnings#nextauth_url
indicating that there is no NEXTAUTH_URL present in the configuration and the app defaults to a localhost configuration.
When running the same application on localhost I can successfully set the environment variable and it gets picked up by the application.
Expected behavior
Amplify should pick up the environment variable NEXTAUTH_URL.
Reproduction steps
Build Settings
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: