Hi,
My app block is added on the Shopify password page.
When a customer interacts with it, I send an HTTP request to my server to store analytics.
I send a POST request to an App Proxy URL, for example:
STORE[dot]myshopify[dot]com/apps/MY_APP/url_endpoint
However, it returns a 302 status code, and the event/analytics click is not logged.
Could anyone please let me know how to overcome this? I have checked and it works fine on all other pages.
I also know that if I use my server URL directly, it does not return a 302 response. However, I would like to use App Proxies as a better practice when recording analytics on the server.
Thank you.
Hi @Ajay_Rabari! App Proxy requests are only forwarded to your backend once the client has passed the storefront password gate. The password page is pre-authentication by definition, so a request fired from it hasn’t cleared the gate yet and gets redirected (302) to /password. That’s exactly why it works on every other page, where the visitor has already entered the password and their session is authenticated, but not on the password page itself. This came up here where a colleague confirmed the same thing, that the client making the proxy request needs storefront access first, otherwise it returns the password/login page.
So for analytics specifically on the password page, there’s no way around it with an App Proxy. Your direct-to-server approach is the right call there!
Thank you @Donal-Shopify for your response. But many times, the direct-to-server approach results in cross-origin (CORS) issues. It is not always possible to fix CORS solely from the server side because Shopify’s platform and browser restrictions can also play a role in how these requests are handled.
What would you suggest ?
Hey Ajay, you’re caught in a bit of a bind here since we usually recommend using App Proxies to address CORS issues, but the password gate intercepts every storefront path (including anything under /apps/) before it reaches the proxy, which is exactly why your call comes back as a 302 to /password.
I haven’t come across any documented workarounds internally, so I submitted your feedback as a feature request - to accommodate App Proxies on the /password page.
There may be non-shopify native methods to workaround this, but I’m not a web dev myself so not best positioned to advise - maybe another member of the community has figured this out already and they can chime in here 