The default port for local development is not parameterized and ignores process.env.PORT
#5013
Replies: 7 comments 7 replies
-
Having exactly the same problem today - so please let me know if you know any work arounds! |
Beta Was this translation helpful? Give feedback.
-
If your local .env(or .env.local, .env.development...) file set |
Beta Was this translation helpful? Give feedback.
-
For anyone still having this issue, I managed to solved it by setting the 4200 port within
NextAuth.js will use the same port as your Next.js app by default, so if you change the port for your Next.js app, NextAuth.js will also use that port for authentication requests. The redirect URLs that NextAuth.js uses will include the port number that you set in your next.config.js or workspace.json file, so the authentication requests will use the same port as your app. Note that if you're using a custom callback URL for your provider (such as http://localhost:4200/api/auth/callback/google), you will need to update the callback URL to include the new port number as well. Please let me know if this works! |
Beta Was this translation helpful? Give feedback.
-
For anyone still having this issue, |
Beta Was this translation helpful? Give feedback.
-
Actually it ignores the port configured in nextjs: I'm running next with I'm navigating to I tried to set The only way is by using |
Beta Was this translation helpful? Give feedback.
-
if anyone still has an issue, as per the next.js config definition: Example, to set it to locahost:3001
Still need to start npm with A |
Beta Was this translation helpful? Give feedback.
-
I've been struggling with this problem for so long... 😤 I haven't found any correct solution yet, and adding a port to NEXTAUTH_URL doesn't work for me. This only occurs on the built production version. ✨ If anyone is looking for a temporary solution then just edit this file: There's this line: Change this port to the target port and then everything will start working. Example: And of course you have to do it again after you have done the package installation (pnpm install) Obviously this is not the right solution. I hope that an official fix will be released soon, because it is very annoying when you host several nextjs apps on one VPS and each one runs on a different port. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
I am using NextAuth in a monorepo with nx with the implication that it's automatically configured to run the server on port 4200. With the pull environment variables from Vercel via the CLI I noticed that NextAuth is falling back to the default URL as denoted here:
next-auth/packages/next-auth/src/react/index.tsx
Lines 43 to 63 in aedabc8
Unfortunately this invokes the
parseUrl
function that asserts the default is always running on port 3000 ignoring anything else:next-auth/packages/next-auth/src/utils/parse-url.ts
Line 16 in aedabc8
This is causing different conflicts and I was curious whether this should be adjusted to respect
process.env.PORT
if it's set and then fall back to port 3000.How to reproduce ☕️
Run the development server on any different port.
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions