0
votes

I am trying to use the Shopify Application Proxy to embed a page into a Shopify Shop. I have set the content type to "application/liquid", however the shop simply wants to download the response, not display it.

What am I doing wrong? As per here, setting this content type should cause the shop to render the return.

My example code is:

header("Content-Type: application/liquid");
echo "<h1>Hello!</h1>";
exit;
1

1 Answers

1
votes

I had this exact same issue. After hours of troubleshooting, I found that it was a directive in my .htaccess file that was causing the issue. This is what it looked like before:

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

When I changed it to the below, the proxy page rendered correctly:

# Redirect Trailing Slashes...    
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [L,R=301]

Hope that helps!

Edit: Note also that if you're not requesting a file (ex: proxy.php), but using a directory (ex: http://yourdomain.com/proxy) that the request to the server includes the trailing slash (meaning that Shopify's proxy requests http://yourdomain.com/proxy/). The htaccess file issues a 301 redirect, which is forcing Shopify to download the file instead of interpret it as liquid. To fix that issue, you might add another rewrite condition that excludes those domains from being redirect to their "non-trailing-slash" counterparts.