#[Solved] Stuck in navigateTo loop
1 messages · Page 1 of 1 (latest)
Hello! I'm AppyHelper, your support bot for Appsmith queries.
It sounds like the issue you're experiencing is due to the "Run on page load" setting for your authentication token checking function. This function redirects to the Main page if a token exists, which might be preventing you from staying on the Login page to make edits.
To solve this, you can modify the function to check if the current page is the Login page before deciding to redirect. Here?s a way you could adjust your function:
- Check the Current Page: Before executing the redirect, check if the current page is the Login page. You can do this by using appsmith.URL.pathname to get the current page's pathname and compare it with the Login page's pathname.
Here's a sample modification you can make in your utils.js file:
export default {
checkAuthTokenAndRedirect: () => {
const token = appsmith.store.token;
const isLoginPage = appsmith.URL.pathname === "/login"; // Adjust "/login" as per your login page's pathname
if (token && !isLoginPage) {
navigateTo('Main'); // Adjust "Main" to your main page's name
}
}
}
- Update the Page Load Setting: Make sure this function is still set to "Run on page load" so it checks the token each time a page is loaded.
This modification ensures that the redirect only happens if the user is not currently on the Login page, allowing you to stay on the Login page for edits when needed.
If you don't find my response helpful, you can request to speak to a human agent.
I cannot do that modification because I can't stay on the Login page to make the changes.
To address the issue where you can't stay on the Login page to make changes due to the automatic redirection, you can temporarily disable the "Run on page load" option for the function that checks the authentication token. This will stop the automatic redirection and allow you to stay on the Login page to make your necessary modifications.
Here's how you can do it:
- Disable 'Run on page load':
- Navigate to the function in your utils.js or wherever the redirect function is implemented.
- Find the setting for "Run on page load" and disable it.
- Make Your Changes:
- With the redirection disabled, you should now be able to stay on the Login page and make the necessary edits.
- Re-enable 'Run on page load':
- Once your changes are complete, remember to re-enable the "Run on page load" setting to ensure your app continues to function as intended with the authentication check.
If you are unable to navigate to the settings due to the redirection, you might need to temporarily remove or comment out the navigation code directly in your code repository or through an API if your project setup allows it. This would require access to the server or platform where your Appsmith application code is hosted.
If you don't find my response helpful, you can request to speak to a human agent.
I wan't to talk to a human agent, please.
Someone from our team will reach out to you on this thread. In the meantime, you can have a look at our documentation to try & resolve your query https://docs.appsmith.com?utm=bot
Organizations build internal applications such as dashboards, database GUIs, admin panels, approval apps, customer support tools, etc. to help improve their business operations. Appsmith is an open-source developer tool that enables the rapid development of these applications. You can drag and drop pre-built widgets to build UI. Connect securely...
Hello! I'm Amelia with Appsmith Support. ?
You can try to fix this by clearing the value of appsmith.store.token. Run removeValue("token") in a JS Object or in the onClick of a button on the page that is accessible to you. Once the value is undefined, the redirect should not get triggered and you should be able to access the page and fix the code.
If that does not work, there is also a more general approach to solving such issues:
- Create a JS Object on the main page (or any page that is accessible to you), and add a 'debugger' statement to a JS function (see an example in the screenshot).
- Set this JS function to run on page load.
- Open the browser's console, and reload the page.
- Once it is reloaded and the JS function where you used the debugger statement runs, you will be able to access the page where you are facing the redirection issue and edit the JS function which contains the navigateTo method. Disable the Run on page load option or add a condition so it won't automatically redirect.
Please let me know if the solution works for you or if you face further issues.