I'm practicing node js for server side of my app and react js for client side of my app, and I made my own auth server in node js to verify the refresh token and issue both of refresh and access tokens and authenticate user credentials too.
However, I don't know how to refresh the access token using the refresh token in user's cookie storage. I know how to check the cookies in request header in node js, but what I'm struggling with now is how frequently I have to send a request from react app to node js server. also, I'm not sure if I can just set interval in users because of memory leaking issues. then, should I just use useEffect hook to refresh access token?
please let me know the general mechanism of using refresh token and access token.
I tried to use setInterval in useEffect hook that depends on the state that contains interval id. I expected it automatically sends a request around 10 minutes before the access token that user has expires. but, it seemed like the app's performance has significantly decreased.