I’m building an embedded app and trying to get the App Proxy option to render a liquid page to work. I have set up the proxy correctly in the app, and have the file returning Content-Type: application/liquid
header, but when I access the page in my test store, it simply downloads the file.
I’m using laravel-shopify from this repository
I have setup correctly app proxy in shopify but problem is that always download the proxy file
I host my project in a Digital Ocean Server
Any idea, thanks a lot !
Here’s the original contents of the public/.htaccess
file in laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
2
Answers
Are you doing an XHR GET instead of hitting the App Proxy in Shopify?
When you want to return Liquid you initiate a GET at the proxy. So for example,
If you are instead making an XHR call to your endpoint, then obviously, even if you return liquid, you are returning data and in this case, your browser is telling you “hey, I don’t know this, so I will initiate a download for you”.
Try hitting the endpoint as a browser request and see what happens.
If Apache is downloading files with a Content-Type header of application/liquid instead of rendering them on Ubuntu, this is likely because the server is not configured to handle Liquid files properly.
To fix this, you can add a MIME type for Liquid files in your Apache configuration file. Here’s how:
Open the Apache configuration file (/etc/apache2/apache2.conf) in a text editor.
Add the following line to the end of the file:
AddType application/liquid .liquid
This tells Apache to treat files with a .liquid extension as Liquid files with a Content-Type header of application/liquid.
After following these steps, Apache should be able to properly handle Liquid files and render them in the browser instead of downloading them with the application/liquid header.