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

chore(docs): update middleware redirect example #10815

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DenilDenilson
Copy link

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

  • [ ✅ ] Documentation
  • Tests
  • [ ✅ ] Ready to be merged

🎫 Affected issues

📌 Resources

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.
Copy link

vercel bot commented May 4, 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 May 6, 2024 6:39pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview May 6, 2024 6:39pm

Copy link

vercel bot commented May 4, 2024

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

A member of the Team first needs to authorize it.

@ndom91 ndom91 changed the title Update protecting Next Middleware Example.mdx chore(docs): update middleware redirect example May 6, 2024
@ndom91
Copy link
Member

ndom91 commented May 6, 2024

Thanks for the cleanup! One small nit, but otherwise LGTM

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

Successfully merging this pull request may close these issues.

None yet

2 participants