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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextRequest types are wrong after nextjs v12.2.0 #5274

Closed
ThomasLarge opened this issue Sep 1, 2022 · 3 comments
Closed

NextRequest types are wrong after nextjs v12.2.0 #5274

ThomasLarge opened this issue Sep 1, 2022 · 3 comments
Labels
question Ask how to do something or how something works TypeScript Issues relating to TypeScript

Comments

@ThomasLarge
Copy link
Contributor

Question 馃挰

CleanShot 2022-09-01 at 15 53 26@2x

On the left are the new types from NextJS and on the Right are the types that getToken are using. When upgrading NextJS passed 12.2.0 the types become incompatible.

CleanShot 2022-09-01 at 15 55 12@2x

This is the type of error when upgrading to NextJS v12.2.5

I believe the fix would be upgrading the nextJS package and making sure the types are updated. I'm more than happy to help out with this if I can be pointed in the right direction for how to get started :)

How to reproduce 鈽曪笍

import { getToken } from 'next-auth/jwt';
import { NextResponse, NextRequest } from 'next/server';

export const middleware = async (req: NextRequest) => {

    const token = await getToken({
      req, // Type error here
      secret: process.env.JWT_SECRET,
      secureCookie: secureCookie(),
    });

    ...

  return NextResponse.next();
};

Contributing 馃檶馃徑

Yes, I am willing to help answer this question in a PR

@ThomasLarge ThomasLarge added question Ask how to do something or how something works TypeScript Issues relating to TypeScript labels Sep 1, 2022
@ThangHuuVu
Copy link
Member

I believe bumping next to 12.2.5 in devDependencies should fix it. Feels a bit weird that a devDependencies causes this, so in addition, I think we need same version of next in peerDependencies too 馃
PR welcomes!

@balazsorban44
Copy link
Member

Closed in #5384

@ryanelian
Copy link

Cannot use Next.js 12.3.1 with the latest Next-Auth package version anymore.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @accelist/nextjs-starter@1.0.0
npm ERR! Found: next@12.3.1
npm ERR! node_modules/next
npm ERR!   next@"12.3.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next@"12.2.5" from next-auth@4.12.0
npm ERR! node_modules/next-auth
npm ERR!   next-auth@"4.12.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Ask how to do something or how something works TypeScript Issues relating to TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants