I have deployed an application made with Next.js to Vercel.
However, in the process of implementing authentication, the getServerSideProps function was used, and when it was checked after deployment, a timeout occurred as shown in the picture above.
I'm currently using the Pro trial and I understand that the timeout is limited to 60 seconds.
But I keep getting timeout.
Do you know how to solve it?
The code I used to authenticate is below.
export const withAuth = (GetServerSidePropsFunction: any) => {
return async (ctx: any) => {
const accessToken = ctx.req.cookies?.accessToken || null;
const refreshToken = ctx.req.cookies?.refreshToken || null;
if (!accessToken && !refreshToken) {
return {
redirect: {
destination: '/login',
statusCode: 302,
},
};
}
const data: any = await isAuthed(accessToken);
if (data.code === 480) {
const refreshData: any = await getRefresh(refreshToken);
if (refreshData.code === 200) {
//access 토큰 다시 저장
ctx.res.setHeader('set-cookie', [cookie.serialize('accessToken', refreshData.data.access, { maxAge: 60 * 60 * 24 })]);
return await GetServerSidePropsFunction(ctx);
}
}
if (!data.data) {
return {
redirect: {
destination: '/login',
statusCode: 302,
},
};
}
return await GetServerSidePropsFunction(ctx);
};
};
