Notifications
Clear all

Indefinite Loop

3 Posts
2 Users
0 Reactions
93 Views
0
Topic starter

Hi Rathan,

I seem to have indefinite loop whenever the refreshToken expires. 

here is the link to the github repo: https://github.com/zakus2023/stock-prediction-portal.git

 

2 Answers
0

Hi Abdul-Razak Issah

I ran your code on my system and noticed an issue. When the refresh token expires, the server enters an infinite loop.

Typically, we don't change the refresh token's expiration time, but if you have changed it and are facing this infinite loop error, you can fix it by modifying your axiosInstance code. Specifically, in your axiosinstance.js file at line 46, you need to use the normal axios request instead of axiosInstance.

Here’s an example:

Your old code:

const response = await axiosInstance.post("/token/refresh/", { refresh: refreshToken, });

The corrected code:

const response = await axios.post(`${baseURL}/token/refresh/`, { refresh: refreshToken, });

Additionally, I noticed another issue in login.jsx where you're using the normal axios for your login API request. Because of this, after the access token expires, you won’t be able to get a new access token since you're not using axiosInstance in your handleFormSubmit function when requesting the token.

Instead, you should import axiosInstance and use it when making post requests to your backend for protected data.

For example, in login.jsx at line 31, update the code to:

const response = await axiosInstance.post

This should resolve the error. If you encounter any more issues, feel free to ask!

6b8140611bf47cf17fbd5e15c5e5dcd6?s=36&d=mm&r=g rathank.com Abdul-Razak Issah Topic starter 06/09/2024 3:26 am

@mohaiminul-islam Thank you very much Muhaimin, it worked perfectly well. Much appreciated.

0

Abdul-Razak Issah, you're most welcome! Feel free to ask if you need any more help.

This post was modified 1 month ago by Rathan Kumar
Share: