Skip to main content

Embed a published app

By default, Retool blocks other pages from framing your apps as one of many mechanisms that keep your apps safe. To place a published app in an iframe, an admin adds Content Security Policy directive rules that name the pages allowed to frame it. This guide covers the three places you can embed an app: an external website, another app, and a classic app.

note

Certain mechanisms for embedding apps, such as the mechanism for custom authentication with Retool API, are not currently supported for apps.

Requirements

You must be an admin or have the delegated Manage advanced settings permission to change these rules. Refer to Customize the Content Security Policy for apps for how the policy works and which source expressions are accepted.

Each app you embed must be published. Refer to Publish an app for the URL of a published app.

Required directives

You may be required to set one or both of the following directives in the Content Security Policy settings.

DirectiveApplies toDefaultEffectRequired for
frame-ancestorsAll apps in your organization.'none'Names the pages allowed to frame the app.All parent types (apps, classic apps, and external websites).
frame-srcThe page holding the iframe.'self'Names what that page can load in an iframe.When embedding an app in another app.
important

Rules take up to 30 minutes to apply across all of your apps.

Embed an app in an iframe

Set frame-ancestors to allow a parent website or app to frame your app:

  1. Go to Settings > App security > Content Security Policy.
  2. Select Add rule, and choose the frame-ancestors directive. Enter the origin of the page that holds the iframe (which is the scheme, host, and optional port), such as https://portal.example.com. To allow several subdomains of one site, use a single-level wildcard such as https://*.example.com.
  3. Add an iframe to that page with the published app URL as its src.
Parent website
<iframe src="https://retool.example.com/rr/app/support-tool" width="100%" height="800"></iframe>

Troubleshooting

Use this section to diagnose and resolve common issues with apps in an iframe.

Why is the iframe blank?

Open your browser's developer console, and find the Content Security Policy violation. The violation names the directive that blocked it.

  • A frame-ancestors violation means the parent page origin is missing from that directive. The following error appears in your developer console: Content Security Policy of your site blocks some resources.
  • A frame-src violation means the parent page is a Retool app and the origin of the app in the iframe is missing from that directive. The following error appears in your developer console: Ensure CORS response header values are valid.

Add the missing origin, then reload the parent page.

Why does the app in the iframe ask the user to sign in?

The browser withholds the app's cookies. In a classic app, confirm Storage and cookies is enabled on the IFrame component, and on a self-hosted instance that ALLOW_SAME_ORIGIN_OPTION is set.

Why has a rule not taken effect?

Rules take up to 30 minutes to apply across all of your apps. Reload the parent page after that time. Confirm the rule records an origin with a scheme, such as https://portal.example.com, and not a bare host name.