Skip to content

Commit

Permalink
feat: priortize NEXTAUTH_URL_INTERNAL (#6814)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThangHuuVu committed Feb 25, 2023
1 parent d0e7689 commit 2fb34ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/next-auth/src/utils/detect-host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** Extract the host from the environment */
export function detectHost(forwardedHost: any) {
// if `NEXTAUTH_URL_INTERNAL` is set, it means NextAuth.js is deployed
// behind a proxy - we prioritize it over `forwardedHost`.
if (process.env.NEXTAUTH_URL_INTERNAL) {
return process.env.NEXTAUTH_URL_INTERNAL
}
// If we detect a Vercel environment, we can trust the host
if (process.env.VERCEL ?? process.env.AUTH_TRUST_HOST)
return forwardedHost
Expand Down

1 comment on commit 2fb34ba

@vercel
Copy link

@vercel vercel bot commented on 2fb34ba Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.