App Proxy redirect 301

pawels
Shopify Partner
1 0 0

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. 

Replies 6 (6)

Mcklen
New Member
12 0 0

Do you solved?

ozzyonfire
Shopify Partner
47 2 17

Try changing the Content-Type header to application/liquid. 

darrynten
Shopify Partner
44 3 14

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?

@darrynten
darrynten
Shopify Partner
44 3 14

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.

@darrynten
mikel3342
Shopify Partner
5 0 0

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

darrynten
Shopify Partner
44 3 14

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" 

@darrynten