php - Why is the content downloaded when I set the application/liquid content type header? -


i'm building little shopify app. wanna add application proxy. works fine - local path causes redirect page.

however if set content-type: application/liquid header page should loaded local shopify page.

but when browser downloads output rather displaying in context of shopify theme.

any ideas doing wrong or might causing this?

from shopify docs:

if http response proxy url has content-type: application/liquid set in headers, shopify evaluate , render liquid code in request's body in context of shop using shop's theme. when used right way, can automatically make app belongs part of shop without manual intervention.

update

it seems working fine on 1 server, keeps downloading on another. trying compare headers no luck far.

i had exact same issue. after hours of troubleshooting, found directive in .htaccess file causing issue. looked before:

# redirect trailing slashes... rewriterule ^(.*)/$ /$1 [l,r=301] 

when changed below, proxy page rendered correctly:

# redirect trailing slashes...     rewritecond %{request_filename} !-f rewriterule ^(.*)/$ /$1 [l,r=301] 

note if you're not requesting file (ex: proxy.php), using directory (ex: http://yourdomain.com/proxy) request server includes trailing slash (meaning shopify's proxy requests http://yourdomain.com/proxy/). htaccess file issues 301 redirect, forcing shopify download file instead of interpret liquid. fix issue, might add rewrite condition excludes domains being redirect theire "non-trailing-slash" counterparts.


Comments