Search code examples
node.jsshopifyshopify-app

Shopify app is not working in express node js


I am developing a shopify app in express nodejs. I have created installation process of app successfully in express nodejs. After app installation, When I have opened the app then I have getting an error of iframe in shopify admin section. Here's the screen shot:-

enter image description here

Also, it said 'Requests to the server have been blocked by an extension'. This issue comes into Google chrome browser. I have also checked in firefox browser. In firefox, it will works fine and shows me two warning that are:- 1. Content Security Policy: Directive ‘child-src’ has been deprecated. Please use directive ‘worker-src’ to control workers, or directive ‘frame-src’ to control frames respectively. 2. Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.

Mainly, it is not working on google chrome.

Please help me regarding this.

Thanks !!!


Solution

  • You need to include app.js provided by shopify if you haven't included it yet.

    In your head section of html, add this

    <head>
      <script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
      <script type="text/javascript">
        ShopifyApp.init({
          apiKey: 'YOUR_APP_API_KEY',
          shopOrigin: 'https://CURRENT_LOGGED_IN_SHOP.myshopify.com'
        });
      </script>
      ...
    </head>
    

    Source