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

feat: Add the support of custom cookieName on the next-auth/middleware #4385

Merged
merged 5 commits into from May 31, 2022

Conversation

42atomys
Copy link
Contributor

Reasoning 💡

When using the advanced custom cookie feature in next-auth, the middleware no longer works due to the fact that it looks for the default names of next-auth. The middleware calls getToken without allowing to override the cookie name

Checklist 🧢

  • Add an option to custom the cookie name (and others cookies if needed in the future)
  • Add documention on Configuration > NextJS page
  • Test by hand

Affected issues 🎟

No

Notes

Try to following the work done in this PR to make more flexible merge in the future #4210

@vercel
Copy link

vercel bot commented Apr 13, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/55C7fRvzBuBHV8CUbuEHBE3x16Gs
✅ Preview: https://next-auth-git-fork-42atomys-main-nextauthjs.vercel.app

[Deployment for f942064 canceled]

@vercel vercel bot temporarily deployed to Preview April 13, 2022 23:59 Inactive
@github-actions github-actions bot added the core Refers to `@auth/core` label Apr 13, 2022
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

Thank you!

My end goal is to match the API of NextAuth within Middleware (so once we are fully edge-compatible, we can reduce the public API surface again, probably in v5), so I appreciate that you used the same API.

As for the docs, I think we should use what's already in https://next-auth.js.org/configuration/options#cookies

Removing the parts that aren't configurable right now.

It looks good to me otherwise. Were you actually be able to test it out?

@vercel vercel bot temporarily deployed to Preview April 14, 2022 20:08 Inactive
@42atomys
Copy link
Contributor Author

42atomys commented Apr 14, 2022

@balazsorban44

Removing the parts that aren't configurable right now.

Done 🎉

Were you actually be able to test it out?

Don't find the middleware testing file to add more tests, any help about implementation of it will be appreciate

@vercel
Copy link

vercel bot commented Apr 17, 2022

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

Name Status Preview Updated
next-auth ✅ Ready (Inspect) Visit Preview May 31, 2022 at 4:27PM (UTC)

@vercel vercel bot temporarily deployed to Preview April 17, 2022 08:49 Inactive
Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

Thanks!

@vercel vercel bot temporarily deployed to Preview May 31, 2022 16:27 Inactive
@balazsorban44 balazsorban44 merged commit 7d8cc70 into nextauthjs:main May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants