Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi everyone, ich have a shopify remix app with an app web pixel, inside the pixel i want to "fetch("/cart.js")" but i always got the error saying "Requests are not allowed to the same origin". I did some search and it turns out that its because web pixel runs inside sandbox. Does anyone know how to fetch cart.js from inside an app web pixel?
Can app proxy help?
@Webstollen wrote:Hi everyone, ich have a shopify remix app with an app web pixel, inside the pixel i want to "fetch("/cart.js")" but i always got the error saying "Requests are not allowed to the same origin". I did some search and it turns out that its because web pixel runs inside sandbox. Does anyone know how to fetch cart.js from inside an app web pixel?
Can app proxy help?
Yes, using an app proxy can help resolve this issue! An app proxy allows you to route requests from your Shopify store to an external URL, which can be useful for fetching data from your app's server.
Here's a general approach to set up an app proxy:
Go to your Shopify Partner Dashboard.
Select your app and navigate to the Configuration section.
Set up the app proxy by specifying the subpath prefix and subpath.
Enter the URL of your proxy server in the Proxy URL field.
Save and release the changes.
For example, if your subpath prefix is apps and your subpath is my-app-proxy, then any path in your online store after https://example.myshopify.com/apps/my-app-proxy will be proxied to the provided proxy URL.
This setup should allow you to fetch cart.js from within your app web pixel without encountering the same-origin policy error.
Hi @Webstollen,
Using an App proxy is a practical solution for overcoming the sam-origin policy restrictions.
1. Set Up the App Proxy
Log in to your Shopify Partner Dashboard and select your app
Specify Proxy Settings by setting Subpath Prefix something like apps and Subpath to my-app-proxy or any custom identifier
Enter the URL of your app's server endpoint that will handle the request, like, https://your-app-server.com/proxy
Save the changes and release the update
Example Proxy Setup:
Storefront Proxy URL: https://your-store.myshopify.com/apps/my-app-proxy
Backend Proxy URL: https://your-app-server.com/proxy
No, an app proxy can seemingly not help. I'm running into a similar issue (not from the cart endpoint tho), in which the error clearly states "RestrictedUrlError: Requests are not allowed to the same origin". Using an app proxy will, by definition, send the request via the same origin (that's the whole point of an app proxy). The real question here is why can't a web pixel make requests to the same origin? It's not explained anywhere in the docs, and it seems like an odd limitation. If anyone comes across this issue and happens to find a reason/solution, please share.
In your specific case, web pixels have access to the cart in the `init` object. Maybe that can help you if you're just reading cart data, not writing it. See docs here: https://shopify.dev/docs/api/web-pixels-api/standard-api/init
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025