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

fix(next-auth): improve typing for using Dynamic Route Segments with auth() #10624

Merged
merged 1 commit into from
Apr 21, 2024

Conversation

arilotter
Copy link
Contributor

@arilotter arilotter commented Apr 17, 2024

☕️ Reasoning

all the plumbing to pass context is already in place,
but the typescript definition doesn't allow context to be passed.
this allows dynamic route segments to be used in auth-wrapped api routes without hacky typescript as any overrides.

this simply adds the typescript typings that reflect what's already being done under the hood.

🧢 Checklist

  • Documentation (behavior hasn't changed, this is already expected behavior, as seen by confusion in the above issue)
  • Tests (behavior hasn't changed)
  • Ready to be merged (in my opinion, yes. i'm already using this patch locally and it works great.)

🎫 Affected issues

Fixes: #9344

Copy link

vercel bot commented Apr 17, 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 Apr 21, 2024 0:32am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Apr 21, 2024 0:32am

all the plumbing to pass context is already in place,
but the typescript definition doesn't allow `context` to be passed.
this allows dynamic route segments to be used in auth-wrapped api routes.

closes nextauthjs#9344
Copy link
Member

@ThangHuuVu ThangHuuVu left a comment

Choose a reason for hiding this comment

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

Thanks! I left a suggestion

packages/next-auth/src/index.tsx Show resolved Hide resolved
@ThangHuuVu ThangHuuVu changed the title allow context when wrapping an app api route with auth() fix(next-auth): improve typing for using Dynamic Route Segments with auth() Apr 21, 2024
@ThangHuuVu
Copy link
Member

Ref: Next.js doc link for Dynamic Route Segments

@ThangHuuVu ThangHuuVu merged commit 2ffaa4d into nextauthjs:main Apr 21, 2024
10 of 11 checks passed
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.

How to implement Dynamic Route Segments with Auth Beta
2 participants