Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
82 stars 9 forks source link

Fetch doesn't automatically inject auth token when request comes from <ui-modal /> #383

Open vadym-perenesenko-moc opened 1 week ago

vadym-perenesenko-moc commented 1 week ago

Describe the bug

Fetch doesn't automatically inject auth token when request comes from <ui-modal />

To Reproduce

Steps to reproduce this behaviour:

  1. If request comes from the app iframe, it is automatically signed.

  2. If request comes from the <ui-modal /> iframe, the request is not signed.

https://github.com/Shopify/shopify-app-bridge/assets/93665352/85a32144-f1b1-44a2-a69a-ca7215bda8d1

I also noticed that the global object in window.shopify does not have an idToken method if you look at the object of the iframe from <ui-modal />

SCR-20240620-pxaz SCR-20240620-pxqm

Packages and versions

Platform

vadym-perenesenko-moc commented 1 week ago

If this is how it was intended, then tell us how to properly sign the requests that come from <ui-modal />we really need it. We render in<ui-modal /> new page using the src.

lmtNoLimit commented 1 week ago

Follow this topic and try using the fetch function from the appFrame @vadym-perenesenko-moc https://shopify.dev/changelog/app-bridge-performance-enhancements-potentially-breaking-changes

Inside modal component call the fetch function from appFrame directly appFrame.fetch

darrynten commented 1 week ago

@lmtNoLimit the link you provided has nothing to do with calling fetch from modals and has no mention of appFrame.fetch

vadym-perenesenko-moc commented 1 week ago

@lmtNoLimit thanks, it helped me. I can now get the idToken from the app iframe and personally sign the necessary requests