Property 'env' is missing in type is missing in Next API Request with auth prop
See original GitHub issuePackage + 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:
- Created a year ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wrote to Clerk on their Discord, Ian said they will look into it!
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.