Error Building A Public Shopify App: Refused To Connect

- 1 answer

I want a public and NOT embedded Shopify app. This app is a sales channel, which imports products from Shopify stores to my e-commerce website. The stores which install the app will have their products listed on my e-commerce website.

I have built the initial steps to install the app and import the products into my e-commerce website.

Now when user clicks on the app icon, I want him to be redirected to the following page which displays the list of imported product:

If the above links returns a list of product as below, the product list will be displayed within the Shopify Admin cosole:

<table data-toggle="table">

        /* more data... */


enter image description here

But if I put the table inside the page layout, which adds <html>, <head> and <body> tag to the result, then the result is not displayed... for example if my app return the following HTML:

    <table data-toggle="table">
     * content of the table 

I would get this result:

enter image description here

I am not sure why I am getting this error: refused to connect

Also it seems like my app is embedded within Shopify admin console, is it possible to build a public app which is not embedded?



Updated Answer

My Shopify app is a Sales Channel and Shopify requires all Sales Channels to be embedded within the admin console (I learnt this the hard way)

In order to make the app embedded inside Shopify admin console we need to remove X-Frame-Options header from response. My application which is developed in ASP.NET MVC and I have added the following code to Global.asax to remove the said header (note that removing X-Frame-Options expose our website to clickjacking attack, so remove the header just for this specific purpose):


protected void Application_PreSendRequestHeaders()
    var routeValues = HttpContext.Current.Request.RequestContext.RouteData.Values;
    if (routeValues.ContainsKey("controller"))
        // make sure you only remove the header for a very specific use case
        if (string.Equals((string)routeValues["controller"], "EmbeddedShopifyController", StringComparison.InvariantCultureIgnoreCase))

Original answer

The reason for this error was that I had configured my app to be embedded. To check if your app is embedded or not, go to your Shopify Partners page:

Apps -> Extensions -> Embedded app

enter image description here

Click on Manage embedded app button, and here you can see if the app is configured to be embedded or not. You can Enable/Disable this setting.

In my case, I disabled the embedded app configuration and my app now works fine.