Declare your app's network access
Declare the external hosts and servers that your app uses in the network_access section of your app configuration file.
Your app's code runs on pages that merchants and customers trust: storefronts, checkout, and the Shopify admin. When you declare the hosts and servers that your app uses, Shopify knows what your app's links and requests should look like. We use the list to protect your app and monitor storefronts for malicious requests.
Declaring the hosts that your app links to also improves the customer experience. Shopify skips the exit interstitial for links from an online store to those hosts.
- List every external host that your app links customers to from the online store in
allowed_navigation_hosts. Only list hosts that you control, such as your app's own domain. - List every external server that your app's code loads from or sends requests to in
allowed_sources. This covers your extensions and the pages that your app serves, such as your app home and HTML or Liquid app proxy pages. - Leave out anything that Shopify serves, such as the files in a theme app extension's
assetsfolder. Leave out your app proxy URL too: the store serves app proxy pages from its own domain.
Anchor to ExamplesExamples
The following examples show code from three parts of an app, and the network_access entries that each one needs. The code is on the left, and the entries that it adds are on the right.
Anchor to Theme app extensionTheme app extension
This app block links to the app's review page, loads a widget from the app's CDN, and fetches reviews from the app's API. The block's own reviews.js file is in the extension's assets folder, so Shopify serves it and it doesn't need an entry.
extensions/reviews/blocks/reviews.liquid
extensions/reviews/assets/reviews.js
shopify.app.toml
Anchor to App proxy pageApp proxy page
This app proxy route renders a Liquid page in the store's theme. The page links to the app's help center and loads the same widget. The store serves the page from its own domain, so the app proxy URL itself doesn't need an entry.
app/routes/apps.reviews.tsx
shopify.app.toml
Anchor to Checkout UI extensionCheckout UI extension
This checkout UI extension fetches the customer's loyalty points from the app's API. To call fetch(), a checkout UI extension also needs the network_access capability in its own shopify.extension.toml file. That capability is separate from the app's [network_access] section.
extensions/loyalty/src/Checkout.jsx
shopify.app.toml
Anchor to Complete configurationComplete configuration
List each host and source once, however many parts of your app use it. Together, the three examples need this configuration:
shopify.app.toml
Anchor to VerifyVerify
Run shopify app deploy. Shopify checks both lists when it creates the app version, and rejects the deploy if an entry doesn't follow the rules in the network_access reference.