I’m pleased to announce a brand new feature that we recently added to the Shopify API: Application Proxies. These will allow you do develop all kinds of crazy things that weren’t possible before, and we’re really excited about it. Let me explain. What’s an App Proxy? An App Proxy is simply a page within a Shopify shop that loads its content from another location of your choosing. Applications can tell certain shop pages that they should fetch and display data from another location outside of Shopify. The really cool thing about the implementation we’ve put together is that if you return data with the application/liquid content-type we’ll run it through Shopify’s template rendering engine before pushing it out to the user. This allows you to create dynamic native pages without having to do anything crazy with iframes. I’ll explain this in more detail later. How Do I Set This Up? We have a great App Proxy tutorial over on our API docs that takes you through the steps, but I’ll summarize them here too. The first thing you need to do is set up the path that should be proxied and where it should be proxied to. This is done from your app’s configuration screen on the Partners dashboard. Once you’ve done that, you’ll need to work out what data you’re going to return when the specified URL is hit. You can return anything you want but for now we’re going to show some very simple stats to get the ball rolling. All my examples assume that you’re using the shopify_app gem as a starting point, but the topics I cover translate directly to all languages. Before we do anything else we need a controller to handle the calls. I generated a ProxyController class and mapped /proxy to hit its index method. I also created a template to render the response. Here’s the controller: class ProxyController < ApplicationController def index end end And here’s the template: <h1>Hello App Proxy World</h1> Really easy so
NayaRead shows a summary and links to the original article. The full article is hosted on shopify.engineering.