-
Notifications
You must be signed in to change notification settings - Fork 430
Open
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
We are in the process of upgrading our sdk from v3 -> v4 in order to upgrade our next application v15 and ran into a critical type issue. It's a bit confusing because the migration docs suggest this API was removed but then seemed to have been added back in v4.9 without a ton of relevant discussion (#1790)
When using auth0.withPageAuthRequired
and providing a custom getServerSideProps
, props
is typed as any
even with InferGetServerSidePropsType<typeof getServerSideProps>
.
This is a clear regression from v3.
Reproduction
- Use nextjs pages router
- Create a page component like so:
import type { InferGetServerSidePropsType } from "next";
import { auth0 } from 'src/lib/auth0';
const PageRepro = (props: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const { foo } = props; // this will be type any
....
}
export const getServerSideProps = auth0.withPageAuthRequired({
async getServerSideProps(ctx) {
if (!ctx.params?.id) {
return { notFound: true };
}
const id = Number(ctx.params.id);
return {
props: {
id, // this is strongly typed as number
},
};
},
});
Additional context
No response
nextjs-auth0 version
^4.9.0
Next.js version
^14.2.25
Node.js version
22.14.0
Amethystix and Ilia-TheNetworkFirm