Amplify/Cognito Authentication Performance Issues

0

• In our NextJS/React application we are using AWS amplify and AWS cognito for auth. • In our NextJS "getServerSideProps" we will authenticate the user on certain pages using this "protectedPageRoute" function.

import { withSSRContext } from "aws-amplify";

export default async function protectedPageRoute({
    context,
    redirectTo,
    getProps
}: Props) {

    const { Auth } = withSSRContext(context);
    try {

        const user = await Auth.currentAuthenticatedUser();
        const userJwtToken = (await Auth.currentSession()).getAccessToken().getJwtToken()

       // rest of code
 
    } catch (error) {
       // catch error code
    }
}

Issue: • When the user first loads the page after their auth token has expired, the re-authentication takes a long time to succeed.

Questions: • Is there a better way to handle authentication on our NextJS server side? • Is there anyway to speed up the re-authentication process?

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠