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

Add additional type #4402

Merged
merged 6 commits into from Apr 22, 2022
Merged

Add additional type #4402

merged 6 commits into from Apr 22, 2022

Conversation

kafelix496
Copy link
Contributor

@kafelix496 kafelix496 commented Apr 17, 2022

Reasoning 💡

I'm trying to use getToken function in _middleware.ts but it complains because req type only has NextApiRequest | Pick<NextApiRequest, "cookies" | "headers">.

Screen Shot 2022-04-17 at 8 06 11 AM

Checklist 🧢

NextRequst type for nextjs _middleware.ts

Screen Shot 2022-04-17 at 8 01 32 AM

  • Documentation
  • Tests
  • Ready to be merged

Yes

Affected issues 🎟

I don't think it affects something else.

`NextRequst` type is for nextjs `_middleware.ts`
@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 Apr 22, 2022 at 11:11AM (UTC)

@github-actions github-actions bot added the core Refers to `@auth/core` label Apr 17, 2022
Copy link
Collaborator

@ubbe-xyz ubbe-xyz 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 think it makes sense as with the introduction of middleware, getToken can also be called with this context.

Now that you're at it, do you mind updating this line here?

https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/next/middleware.ts#L84

We won't need the cast to any anymore 💆🏽‍♂️

@ubbe-xyz ubbe-xyz self-assigned this Apr 20, 2022
@kafelix496
Copy link
Contributor Author

Thank you for checking my PR :)

I agree with what you mentioned! I remove as any in there.

@vercel vercel bot temporarily deployed to Preview April 21, 2022 13:33 Inactive
@kafelix496
Copy link
Contributor Author

kafelix496 commented Apr 21, 2022

@lluia I updated the code to import NextRequest from next/server. And also, I realized that it's not a type.

@ubbe-xyz ubbe-xyz merged commit 9f40cd1 into nextauthjs:main Apr 22, 2022
@vercel vercel bot temporarily deployed to Preview April 22, 2022 11:11 Inactive
@ubbe-xyz ubbe-xyz mentioned this pull request Apr 26, 2022
1 task
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