"Failed to execute 'postMessage' on 'DOMWindow'" error logged when initializing App Bridge

Hi there,

We’re currently in the process of migrating to App Bridge and all is going well except for one minor glitch. I’m following the guide here https://shopify.dev/apps/tools/app-bridge/getting-started#authenticate-with-oauth

I break out of the iframe to initiate the OAuth flow. When the OAuth flow is complete, the user lands at our embeddable app (https://shopify.dev.nos.to/hub/shopify/shopify-44907954330). At this stage, I render HTML that creates the App Bridge app with the snippet below:

<script src="https://unpkg.com/@shopify/app-bridge@2"></script>
<script type="application/javascript">
  var AppBridge = window['app-bridge'];
  var app = AppBridge.createApp({
    apiKey: '${shopifyClientId}',
    host: '${shopifyHost}' // host parameter mentioned here https://shopify.dev/apps/tools/app-bridge/retrieve-the-host
  });
</script>

The app correctly redirects back to the Shopify admin with our app correctly embedded in the iframe. The following error gets logged 3 times at this stage however. It doesn’t appear to impact any functionality, so I’m wondering can this be ignored or do I need to address it?

Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://gary-nosto-local.myshopify.com’) does not match the recipient window’s origin (‘https://shopify.dev.nos.to’)
Many thanks,

Gary

1 Like