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(ts): remove TS workaround for withAuth #4926

Merged
merged 4 commits into from Jul 15, 2022
Merged

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Jul 13, 2022

Removes workaround for typing withAuth's inner Middleware. Closes #4925. Fixes #4817.

We control what happens inside withAuth so we shouldn't require the user to type anything themselves.

This is now correctly typed:

import { withAuth } from "next-auth/middleware"

export default withAuth(
  function middleware(req) {
    console.log(req.nextauth.token)
  }
)

// or

export default withAuth((req) => {
  console.log(req.nextauth.token)
})

I also noticed that NextMiddleware could not return void which I opened a PR for upstream in Next.js vercel/next.js#38625

@vercel
Copy link

vercel bot commented Jul 13, 2022

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

1 Ignored Deployment
Name Status Preview Updated
next-auth ⬜️ Ignored (Inspect) Jul 14, 2022 at 11:17PM (UTC)

@github-actions github-actions bot added the core Refers to `@auth/core` label Jul 13, 2022
@balazsorban44 balazsorban44 changed the title Fix/middleware ts fix(ts): remove TS workaround for withAuth Jul 13, 2022
@balazsorban44 balazsorban44 temporarily deployed to Preview July 14, 2022 23:18 Inactive
@github-actions
Copy link

🎉 Experimental release published on npm!

npm i next-auth@0.0.0-pr.4926.25a4fa9f
yarn add next-auth@0.0.0-pr.4926.25a4fa9f

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.

Lgtm! 🙌

@balazsorban44 balazsorban44 merged commit 46eedee into main Jul 15, 2022
@balazsorban44 balazsorban44 deleted the fix/middleware-ts branch July 15, 2022 02:39
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.

Middleware NextRequest params type error
2 participants