Web Pixels `browser.sendBeacon` does not fire request for same origin URL

kai9
Shopify Partner
2 0 4

Our development team is utilizing Shopify's extension Web Pixels for our operations. However, we have noticed that due to some changes on Shopify's side around May 17, our existing implementation of Web Pixels is no longer functioning as expected.

 

Upon investigating, we found that we are making requests using the `browser.sendBeacon` (https://shopify.dev/docs/api/pixels/pixel-extension#browser-sendbeacon-url-data) function that is available with Web Pixels. However, it appears that we are being caught in the following condition check within `sendBeacon`:

 

if (
n.href.includes(self.location.origin) &&
!n.href.match(/\/\.well-known\/shopify\/monorail\/unstable\/produce_batch/)
) throw new y(`Request are not allowed to the same origin: ${ n.href }`);

 

Screenshot_2023-05-29_at_9_12_11.png

 

 

We are making requests to our backend via the App Proxy, which is why we are encountering issues with the same origin check.

 

In order to identify users when sending requests from Web Pixels, we are routing these through the App Proxy. We are unsure of how to bypass this check. Could you please advise us on how to proceed?

 

Reply 1 (1)

fzngagan
Shopify Partner
2 0 0

I resorted to directly making a request to my app. But in that case, how to verify if that request is legit?