extend NextRequest
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
I need help with adding the 'auth' property to NextRequest, could anyone help?
1 Reply
Spectacled bearOP
I've tried
and made sure I'm not importing NextRequest from next/server (as to not override the new declaration) and I'm getting the following error:
import { NextRequest as OriginalNextRequest } from "next/server";
declare global {
declare interface NextRequest extends OriginalNextRequest {
auth: any
}
}and made sure I'm not importing NextRequest from next/server (as to not override the new declaration) and I'm getting the following error:
Type '(next: NextMiddleware) => (request: NextRequest, _next: NextFetchEvent) => Promise<NextMiddlewareResult>' is not assignable to type 'MiddlewareFactory'.
Type '(request: NextRequest, _next: NextFetchEvent) => Promise<NextMiddlewareResult>' is not assignable to type 'NextMiddleware'.
Types of parameters 'request' and 'request' are incompatible.
Property 'auth' is missing in type 'import("p:/cts-final/frontend/node_modules/next/dist/server/web/spec-extension/request").NextRequest' but required in type 'NextRequest'.