Category: JS Objects
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Embedded App in HTML Iframe Resets to Login Page On Reload

Issue

I am embedding my application in an HTML iframe and every time I reload the page, it shows the login page instead of the current running page. The issue does not occur when I directly access the application URL in a browser. I have a custom login page inside the application with tabs for different pages. The current tab value is stored in local storage but is resetting to the default tab on page reload. I tried setting the current tab value onPageLoad using JSObjects, which worked locally but not on the actual domain server. There are no errors in the console logs.

Resolution

When an Appsmith app is embedded in an HTML <iframe>, reloading the host page may redirect the app back to the login page instead of keeping the current tab or page. This does not happen when accessing the app directly.

The app uses a custom login page, and the active tab is stored in local storage. On reload, this value resets to the default, even though no console errors appear. The issue may work locally but fail on the deployed domain.

Root Cause

This behavior is typically caused by:

  • Local storage or authentication state not persisting as expected in an iframe
  • Authentication checks running before the stored tab value is restored

Resolution

  1. Verify state persistence
    • Bind the stored tab value to a Text widget to confirm whether it survives a reload.
  2. Review onPageLoad logic
    • Ensure JSObjects that restore the tab run before navigation or auth checks.
  3. Validate authentication
    • Confirm tokens or session values are available inside the iframe before redirecting to the login page.