I'm trying to add a link to redirect users to the create page, But when I clicked on the link I got the following error:
TypeError: Cannot read properties of undefined (reading 'cookies')
Link code :
<Link href={link}>Add New Employee</Link>
getInitialProps // _app.tsx
MyApp.getInitialProps = async (context: any) => {
const {req, res, pathname} = context.ctx;
const {language, auth_key} = req.cookies;
return {
lang: language ?? 'ar',
token: auth_key ?? null,
}
};