-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
chore(docs): update middleware redirect example #10815
Conversation
The current example of protecting with Next.js middleware isn't functioning. I propose a new example that works correctly and is easy to understand.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@DenilDenilson is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for the cleanup! One small nit, but otherwise LGTM |
Co-authored-by: Nico Domino <yo@ndo.dev>
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.
Yeah nice improvement, thanks!
The current example of protecting with Next.js middleware isn't functioning. I propose a new example that works correctly and is easy to understand.
☕️ Reasoning
In the documentation for protecting resources with Next.js middleware, the example code isn't functioning correctly. The 'replace' method replaces the first '/' in the URL (https://...) with 'loginlocalhost:/', which is an error. I've made changes to the code in the documentation to ensure it works properly by using the URL constructor with the base URL and the new pathname. Additionally, I've implemented a new validation to prevent infinite redirects.
🧢 Checklist
🎫 Affected issues
📌 Resources