Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use host and proto headers to determine request origin if AUTH_URL is not set #12421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bfichter
Copy link

☕️ Reasoning

The v5 docs state that AUTH_URL "is mostly unnecessary with v5 as the host is inferred from the request headers," but this is only the case in some areas of @auth/core, and the url of the request is often the fallback for determining URLs in the framework. But in the case that the app is running behind a reverse proxy or in a number of other networking setups, requests to @auth/core from next-auth won't have a relevant url (0.0.0.0 observed in our use case) and authentication will fail in a number of ways without AUTH_URL set.

This change checks request headers (if they're set) to determine the url to send to @auth/core, in the case that AUTH_URL or NEXTAUTH_URL are not set. This properly cuts reliance on AUTH_URL (in our use case) and also as a bonus enables multiple authentication urls to be used in a given system.

Possibly this behavior should be behind some config if we want to make it opt in. If so I'm happy to add that.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

@bfichter bfichter requested a review from ThangHuuVu as a code owner December 25, 2024 23:03
Copy link

vercel bot commented Dec 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 25, 2024 11:07pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Dec 25, 2024 11:07pm

Copy link

vercel bot commented Dec 25, 2024

@bfichter is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant