For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
hi yall, as the title said, when I want to send request using fetch to admin API or my server API, It gives me back "Uncaught (in promise) NetworkAccessDeniedError: permission to use fetch() must be specified under [capabilities] with flag "network_access = true"; this can be done within your extension's configuration. View the docs for more information:". Even though I have added the network_access = true in the extension Config file and check the nable network access in checkout UI extensions box in shopify partner, nothing changed. Can anyone help me out here? any help would be deeply appreciated
Solved! Go to the solution
This is an accepted solution.
Hey @cvargas31
Glad to hear it! The Admin API should only be hit from a server environment to keep keys secure. So you'll need to proxy the request through your app. Alternatively, consider storing the data in a metafield (if possible). From the docs:
Instead of fetching data with an external network call, consider retrieving the data from a metafield. Your app may be able to use the Admin API to write metafields on the shop, product, or customer ahead of checkout.
Retrieving data from metafields during checkout is faster since it won't introduce an external network call. This allows you to rely on Shopify for the uptime, scaling, and durability of the data storage.
Scott | Developer Advocate @ Shopify
Hey @TuanDangA
Have you tried restarting/reinstalling? Can I see your config file please. Also, what's your app ID?
Scott | Developer Advocate @ Shopify
Thanks, Scott for replying, I have made the network denied error by restarting, but not when I fetch adminAPI, it returns a cors error. Can you help me with that?
This is an accepted solution.
Hey @cvargas31
Glad to hear it! The Admin API should only be hit from a server environment to keep keys secure. So you'll need to proxy the request through your app. Alternatively, consider storing the data in a metafield (if possible). From the docs:
Instead of fetching data with an external network call, consider retrieving the data from a metafield. Your app may be able to use the Admin API to write metafields on the shop, product, or customer ahead of checkout.
Retrieving data from metafields during checkout is faster since it won't introduce an external network call. This allows you to rely on Shopify for the uptime, scaling, and durability of the data storage.
Scott | Developer Advocate @ Shopify
Im having the same issue, even though the access is being provided in the .toml file