A space to discuss online store customization, theme development, and Liquid templating.
Hello,
I created an application that uses a proxy, but unfortunately the response from the Shopify server after calling the url returns 301 and redirects to the address which is inserted as Proxy URL.
For example request for: https://myshop.com/apps/my-proxy?color=red&productId=1231
Response headers are:
HTTP/1.1 301 Moved Permanently Server: nginx Date: Fri, 22 Feb 2019 14:44:44 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive X-Sorting-Hat-PodId: 117 X-Sorting-Hat-PodId-Cached: 1 X-Sorting-Hat-ShopId: MYSHOPID X-Sorting-Hat-PrivacyLevel: default X-Sorting-Hat-FeatureSet: default X-Sorting-Hat-Section: pod X-Sorting-Hat-ShopId-Cached: 1 Set-Cookie: secure_customer_sig=; path=/; expires=Tue, 22 Feb 2039 14:44:43 -0000; secure; HttpOnly X-Download-Options: noopen X-Dc: ash,ash Location: https://myproxyurl.com/creator/prod?color=red&path_prefix=%2Fapps%2Fmy-proxy&productId=1231&shop=myshop.com.myshopify.com&signature=XXXtimestamp=YYYYYY X-XSS-Protection: 1; mode=block X-Permitted-Cross-Domain-Policies: none X-Content-Type-Options: nosniff X-Request-ID: 86a1e144-bd93-479b-a47e-3add55aa34d5 Set-Cookie: cart_sig=YYYYYY; path=/; expires=Fri, 08 Mar 2019 14:44:43 -0000; HttpOnly X-Content-Type-Options: nosniff
Is this the correct operation? It should not be that the user is still on the same domain of the store (with /apps/my-proxy), and only the content of app is on is displayed to him. When I call the Proxy URL it directly returns the 200 code, so it`s It is certainly not that my application responds with request 301.
Do you solved?
Try changing the Content-Type header to application/liquid.
I'm also seeing this on one of my apps, the app proxy returns a 200 and remains on the host store domain in development (stays on myshopify.com) but in production the app proxy returns a 301 to the app proxy url (leaves myshopify.com to myapp.com/proxy/endpoint.js)
any ideas?
Turns out there was a redirection rule in the htaccess that was causing the server to respond with a 301 which Shopify passed along.
Removing this resolved the problem and the app proxy now responds with a 200 as expected.
Hey, i have same issue with domain in development (stays on myshopify.com)
and custom domains on production, can you share the solution? there is no redirection from my server side
Thanks
Check for a 30x redirect in either your web server or domain config, the .htaccess file (if apache), and any middlewares you have
In my case it was a 301 in the applications .htaccess and reconfiguring the server to not 301 on the app proxy was the solution
The last sentence on the official app proxy docs page was the clue I needed to get there - it states: "Also, any 30x redirects are followed"
Wanted to add to this, in my case, I was making fetch calls to URLS that ended with forward slashes
e.g. /path/to/endpoint/ which caused/triggered a redirect by my laravel lumen backend to /path/to/endpoint without the forward slash.
it wasn't immediately obvious to me why the 301 redirects were happening but this thread pointed me in the right direction, so thank you for this. the 301 redirects were changing my POST requests to GET requests and dropping the form data. the solution, at least for me, was to change my client-side fetch requests so that they don't end with forward slashes '/'
this is obviously very dependent on how each backend is setup and how they handle redirects but im pretty sure, most of the time, it will likely be related to adding or not adding forward slashes to the end of your fetch request. i hope this helps someone else who doesn't have access to tinkering around with the backend.