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
Topic summary
Developers are encountering a NetworkAccessDeniedError when attempting to use fetch() in Checkout UI Extensions to call the Admin API or external server APIs. The error message indicates that network_access = true must be specified under [capabilities] in the extension’s configuration file.\n\nKey Issue:\nEven after adding network_access = true to the extension config file and enabling the \
Hey @TuanDangA
Have you tried restarting/reinstalling? Can I see your config file please. Also, what’s your app ID?
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?
Im having the same issue, even though the access is being provided in the .toml file
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.
Hey @cvargas31
Have you restarted + followed these steps?