You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
will log undefined in console before the actual port 3000 is logged.
with that server running, starting a new dev server in a different terminal will log undefined
before trying the 3001 port and eventually logging that.
lastly, running the dev server with the --port flag set, results in the same behavior, we first get undefined log before 3002:
Current vs. Expected behavior
I want to verify that a URL is correct before starting the server, and want to match the ports:
import{env}from"./src/env.mjs";constnextAuthPort=newURL(env.NEXTAUTH_URL).port;if(env.NODE_ENV==="development"&&nextAuthPort!==String(env.PORT)){thrownewError([`❗ NEXTAUTH_URL (${env.NEXTAUTH_URL}) doesn't match with PORT (${env.PORT}).`,`Either update your the URL in your .env file or make sure to run your dev server on port ${nextAuthPort}.`,].join(" "),);}/** @type {import("next").NextConfig} */constconfig={};exportdefaultconfig;
Unfortunately, this doesn't work if the port variable is initially undefined. Is there any way you could load this before loading next config, so that the variable isn't undefined to start with?
Verify canary release
I verified that the issue exists in the latest Next.js canary release
The Next.js config is loaded in different phases, and is likely not the correct place to check this. This has always been the same behavior. (Checked back til v11).
Sidenote, NextAuth.js can infer the host+port so NEXTAUTH_URL isn't even necessary to be set anymore.
The Next.js config is loaded in different phases, and is likely not the correct place to check this. This has always been the same behavior. (Checked back til v11).
Hmm that's a bummer...
Sidenote, NextAuth.js can infer the host+port so NEXTAUTH_URL isn't even necessary to be set anymore.
That doesn't really matter though as the goal was to warn the user that they are doing something unexpected. If I have localhost:3000 set in the oauth app callback it doesn't matter if nextauth can infer that since it's going to cause a 400 request to the auth provider no matter what. We think it's better to be explicit and error early to provide the best developer experience.
Where would be the best place to check this if the Next.js config isn't?
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/juliusmarminge/port
To Reproduce
will log
undefined
in console before the actual port3000
is logged.with that server running, starting a new dev server in a different terminal will log
undefined
before trying the
3001
port and eventually logging that.lastly, running the dev server with the
--port
flag set, results in the same behavior, we first getundefined
log before3002
:Current vs. Expected behavior
I want to verify that a URL is correct before starting the server, and want to match the ports:
Unfortunately, this doesn't work if the port variable is initially undefined. Is there any way you could load this before loading next config, so that the variable isn't undefined to start with?
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.19 pnpm: 8.6.2 Relevant Packages: next: 13.5.5-canary.17 eslint-config-next: N/A react: 18.0.0 react-dom: 18.0.0 typescript: 5.0.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Additional context
t3-oss/create-t3-app#1596
The text was updated successfully, but these errors were encountered: