# Cors Error while using api proxy in checkout ui extensions node template

**URL:** <https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503>\
**Category:** Extensions\
**Tags:** checkout-ui-ext\
**Created:** [February 17, 2025, 6:19pm UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503 "2025-02-17T18:19:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravindra\_Yadav](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Ravindra\_Yadav](https://community.shopify.dev/u/Ravindra_Yadav)\
**Post date:** [February 17, 2025, 6:19pm UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/1 "2025-02-17T18:19:28Z")

</div>

I’m trying to make an API call to my Express app from a Checkout UI extension using an API proxy, but I’m still encountering a CORS error.  
checkout.jsx -

```auto
const response = fetch("https://dev-ravindra.myshopify.com/apps/survey", { 
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "Access-Control-Allow-Origin": "*", 
          },
          body: JSON.stringify({ surveyResponse: "example" }), 
        }

```

---

<div class="post-metadata">

**Author:** ![Liam-Shopify](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/liam-shopify/32/6_2.png) [@Liam-Shopify](https://community.shopify.dev/u/Liam-Shopify)\
**Post date:** [February 18, 2025, 8:01am UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/2 "2025-02-18T08:01:44Z")

</div>

Hi Ravindra

Here are some steps you could try to resolve this issue:

1. **Use the Shopify API Proxy** : Shopify provides an API proxy feature that allows you to route requests through the Shopify domain, avoiding CORS issues. Ensure that your app is configured to use the API proxy. You can define the proxy in your app’s configuration and make requests to `/apps/<your-app-name>` instead of directly to your server.
2. **Set Up CORS in Your Express App** : Ensure your Express app is configured to handle CORS properly. Use the `cors` middleware to allow requests from the Shopify domain. For example:

```auto
   const cors = require('cors');
   app.use(cors({
       origin: 'https://<your-shopify-store>.myshopify.com',
       methods: ['GET', 'POST'],
       allowedHeaders: ['Content-Type', 'Authorization']
   }));

```

1. **Ensure Proper Headers** : In your fetch request, avoid setting `Access-Control-Allow-Origin` in the headers. This header is meant to be set by the server, not the client. Remove it from your fetch request.

---

<div class="post-metadata">

**Author:** ![Ravindra\_Yadav](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Ravindra\_Yadav](https://community.shopify.dev/u/Ravindra_Yadav)\
**Post date:** [February 18, 2025, 8:56am UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/3 "2025-02-18T08:56:59Z")

</div>

I tried this, but I’m still getting a CORS error. I also added a `console.log` to check if my middleware was executing, but it didn’t print anything. This means the request is likely being handled elsewhere before reaching my middleware. Since I’m using the Shopify Express template, it seems that one of the existing middlewares in the template is executing first and preventing mine from running.

---

<div class="post-metadata">

**Author:** ![Liam-Shopify](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/liam-shopify/32/6_2.png) [@Liam-Shopify](https://community.shopify.dev/u/Liam-Shopify)\
**Post date:** [February 18, 2025, 11:53am UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/4 "2025-02-18T11:53:37Z")

</div>

Is this the template you’re using? [GitHub - Shopify/shopify-app-js](https://github.com/Shopify/shopify-app-js)

---

<div class="post-metadata">

**Author:** ![Ravindra\_Yadav](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Ravindra\_Yadav](https://community.shopify.dev/u/Ravindra_Yadav)\
**Post date:** [February 18, 2025, 12:07pm UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/5 "2025-02-18T12:07:53Z")

</div>

No i am using this template

> **[GitHub - Shopify/shopify-app-template-node](https://github.com/Shopify/shopify-app-template-node)**
>
> Contribute to Shopify/shopify-app-template-node development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Liam-Shopify](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/liam-shopify/32/6_2.png) [@Liam-Shopify](https://community.shopify.dev/u/Liam-Shopify)\
**Post date:** [February 18, 2025, 12:23pm UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/6 "2025-02-18T12:23:16Z")

</div>

And the app is installing correctly, correct? This error is only happening in the context of a checkout extension? Have you reviewed this doc: [Configuration](https://shopify.dev/docs/api/checkout-ui-extensions/2025-01/configuration#network-access:~:text=a%20discount%20code.-,App%20Proxy,-UI%20extensions%20can)

> UI extension requests made to the App Proxy of password protected shops is not supported.

Is the store password protected?

---

<div class="post-metadata">

**Author:** ![Carlos\_Valdivia\_Paiv](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@Carlos\_Valdivia\_Paiv](https://community.shopify.dev/u/Carlos_Valdivia_Paiv)\
**Post date:** [April 24, 2025, 6:33am UTC](https://community.shopify.dev/t/cors-error-while-using-api-proxy-in-checkout-ui-extensions-node-template/8503/7 "2025-04-24T06:33:48Z")

</div>

If I am testing in a developing store, it always will have a password? how I can handle this? How I can develop?
