oidc does not exist on Request type #5897
-
Issueimport { Request } from 'express'
...
export async function getServerSideProps(context: GetServerSidePropsContext & { req: Request }) {
const variable = context.req?.oidc?.user['parameter'];
}Tried
|
Beta Was this translation helpful? Give feedback.
Answered by
Aakash1103Jha
Apr 28, 2023
Replies: 2 comments
-
|
are you using next.js? if yes you cannot mix express Request type with it |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@CalebJamesStevens, like @dtsuper3 said, you can't mix an express and nextjs. If you want to have
import type { GetServerSidePropsContext as OriginalGetServerSidePropsContext } from "next/types";
declare module "next" {
export type GetServerSidePropsContext<
Q extends ParsedUrlQuery = ParsedUrlQuery,
D extends PreviewData = PreviewData,
> = OriginalGetServerSidePropsContext<Q, D> & {
req: {
oidc: string; // use the correct type here
};
};
export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery,
D extends PreviewData = PreviewData,
> = (context: GetServerSidePropsContext<Q, D>) => Promise<GetServerSidePropsResult<P>>;
}
export {}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
IamLizu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

@CalebJamesStevens, like @dtsuper3 said, you can't mix an express and nextjs.
If you want to have
oidcin thereqobject, you will need to modify theGetServerSidePropsContexttype.Try doing this:
next.d.tsfile in your project and add the following code in it.oidcproperty in it.