Top Level redirect in the Shopify node-express template stopped working 3/6/2023 (or so)

Top Level redirect in the Shopify node-express template stopped working 3/6/2023 (or so)

dbleeker
Shopify Partner
9 0 5

Hello all,

 

For some reason the top level redirect code stopped working.   The result is that when some stores load, nothing happens.  It appears that they need to re-auth. Here's the page that the app template returns to the client during 'top level auth':

 

export default function topLevelAuthRedirect({ apiKey, hostName, shop }) {
  return `<!DOCTYPE html>
<html>
  <head>
    <script src="https://unpkg.com/@shopify/app-bridge@3"></script>
    <script>
      document.addEventListener('DOMContentLoaded', function () {
        if (window.top === window.self) {
          window.location.href = '/auth?shop=${shop}';
        } else {
          var AppBridge = window['app-bridge'];
          var createApp = AppBridge.default;
          var Redirect = AppBridge.actions.Redirect;

          const app = createApp({
            apiKey: '${apiKey}',
            shopOrigin: '${shop}',
          });

          const redirect = Redirect.create(app);

          redirect.dispatch(
            Redirect.Action.REMOTE,
            'https://${hostName}/auth/toplevel?shop=${shop}',
          );
        }
      });
    </script>
  </head>
  <body></body>
</html>`;
}
 
I have not modified the code since it was created by the CLI.  The 'redirect.dispatch()' apparently does nothing.
 
I've been able to debug in the browser with Chrome devtools and copied the value of 
'https://${hostName}/auth/toplevel?shop=${shop}'.  When I paste the url into the browser it launched the shopify app and works from then on (I suspect it successfully acquired a ne token).
 
I've tried for several days to get to the bottom of the issue without success, including various app-bridge versions.  Any advice would be appreciated
 
Regards
Replies 3 (3)

alifaiz1804
Shopify Partner
12 0 3

Hi @dbleeker did you find a solution for this?

ShopifyDevSup
Shopify Staff
1453 238 511

Hi @dbleeker,

 

If you'd like to post an issue report about App Bridge the public GitHub repository's issue board is at https://github.com/Shopify/shopify-app-bridge/issues.

 

Hope you have a great day

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mizzimizzi
Shopify Partner
5 0 0

Hi, I'm having the same problem. Any solution?