-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: respect protocol too, when host is trusted (#7214)
* fix: respect protocol too when host is trusted * simplify
- Loading branch information
1 parent
0711d32
commit 6edb6dd
Showing
6 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
packages/next-auth/src/utils/detect-host.ts → ...ages/next-auth/src/utils/detect-origin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/** Extract the host from the environment */ | ||
export function detectHost(forwardedHost: any) { | ||
/** Extract the origin from the environment */ | ||
export function detectOrigin(forwardedHost: any, protocol: any) { | ||
// If we detect a Vercel environment, we can trust the host | ||
if (process.env.VERCEL ?? process.env.AUTH_TRUST_HOST) | ||
return forwardedHost | ||
return `${protocol === "http" ? "http" : "https"}://${forwardedHost}` | ||
|
||
// If `NEXTAUTH_URL` is `undefined` we fall back to "http://localhost:3000" | ||
return process.env.NEXTAUTH_URL | ||
} |
6edb6dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
next-auth-docs – ./docs
next-auth-docs-authjs.vercel.app
next-auth-docs-dun.vercel.app
www.next-auth.js.org
next-auth-docs-git-v4-authjs.vercel.app
next-auth.js.org
v4.authjs.dev