question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'env' is missing in type is missing in Next API Request with auth prop

See original GitHub issue

Package + Version

  • @clerk/nextjs@3.8.1
  • @clerk/types@2.20.0
  • @clerk/clerk-sdk-node@3.9.0

Description

Argument of type '(req: WithAuthProp<NextApiRequest>, res: NextApiResponse) => void' is not assignable to parameter of type 'Middleware'.
  Types of parameters 'req' and 'req' are incompatible.
    Type 'WithAuthProp<Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>' is not assignable to type 'WithAuthProp<NextApiRequest>'.
      Property 'env' is missing in type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>> & { auth: { sessionId: string | null; userId: string | null; getToken: ServerGetToken; claims: ClerkJWTClaims | null; }; }' but required in type 'NextApiRequest'.ts(2345)

Here is the code:

// pages/api/get-authenticated-user.ts
import { withAuth, WithAuthProp } from '@clerk/nextjs/api';
import type { NextApiRequest, NextApiResponse } from 'next';

export default withAuth(
  (req: WithAuthProp<NextApiRequest>, res: NextApiResponse) => {
    const { sessionId } = req.auth;

    if (!sessionId) {
      return res.status(401).json({ id: null });
    }

    return res.status(200).json({ id: sessionId });
  }
);

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Renetnielsencommented, Aug 1, 2022

I wrote to Clerk on their Discord, Ian said they will look into it!

0reactions
SokratisVidroscommented, Aug 2, 2022

Folks, we’ve started working on a fix. It requires some internal typing restructuring and you should expect a fix by the end of this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property is missing in type but required in type
Property 'name' is missing in type 'AppEvent' but required in type 'TestEvent'. So, this type AppEvent cannot have any additional properties.
Read more >
`OAuthConfig` type missing `scope` property · Issue #2938
The OAuthConfig interface is missing the scope property. Is this a bug in your own project? No. How to reproduce ☕️. import NextAuth...
Read more >
next.config.js: Redirects
missing is an array of missing objects with the type , key and value properties. Redirects are checked before the filesystem which includes...
Read more >
Options | NextAuth.js
Options are passed to NextAuth.js when initializing it in an API route. ... The session object and all properties on it are optional....
Read more >
How To Authenticate SOAP Requests | Documentation
Configure Authorization. To configure your authorization, use the options that are available on the Auth tab and the corresponding request properties. The Auth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found