I am developing a Next.js
web application with next-auth
for authentication, and I've encountered a warning message in my development console when running the application. The message looks like this:
Reload env: .env.local
○ compiling /signin/page ...
✓ Compiled /signin/page in 5s (602 modules)
✓ Compiled /api/auth/[...nextauth]/route in 2.1s (975 modules)
[next-auth][warn][NEXTAUTH_URL]
I am using Next.js version 13.5.2
along with pnpm
, and I have set up my environment variables in my .env
file as follows:
GOOGLE_CLIENT_ID=<CLIENT_ID>
GOOGLE_CLIENT_SECRET=<CLIENT_SECRET>
AUTH_SECRET=<AUTH_SECRET>
I would like to understand the meaning of this warning message and whether I need to address it in my Next.js application. How can I resolve this warning?
I followed the setup instructions in the next-auth
documentation, including configuring my .env
file with necessary environment variables such as GOOGLE_CLIENT_ID
, GOOGLE_CLIENT_SECRET
, and AUTH_SECRET
.
NEXTAUTH_URL
is the canonical url of your Next.js app.
On Vercel deployments, we will read the VERCEL_URL environment variable, so you won't need to define NEXTAUTH_URL.
https://next-auth.js.org/warnings#nextauth_url
Since you are running the application in your local, you need to set it in .env.local
NEXTAUTH_URL=http://localhost:3000
Note: if your application url is different, please update the url as required.