Access Shopify API from extension-only app

Is there a way to make a direct api request on Theme App Extension? I’m trying to make requests to shopify API on an extension-only app.

I tried to use fetch to call graphql API. It worked on development store, but when I installed the app on a real store it started to throw an cors error.

Samirjs_0-1734320096351.png

Hi @Samirjs

The issue you’re facing happens because Shopify’s API doesn’t allow direct requests from the browser due to CORS restrictions (Read more about it here) . This is done for security reasons. Here are some solutions:

  1. Use a Backend Server:

    • Instead of calling the Shopify API directly from your theme, send the request to your own server.
    • Your server will then make the request to Shopify’s API and send the response back to the theme.
  2. Use Shopify App Proxy:

    • Shopify provides App Proxies to help you securely fetch data.
    • You can configure a proxy in your app’s admin under App Setup > App Proxy.
    • This way, the theme makes requests to a safe proxy URL, and your server handles the API calls.

Unfortunately, direct client-side API calls aren’t allowed in live stores as Shopify’s security model blocks such attempts to prevent abuse. Setting up a backend or app proxy will solve the issue :blush:

I hope this helps

Best regards,
Daisy

1 Like