CORS Issue: from Shopify demo store via my theme extension to Remix App Hosted apis on my VPS

Solved

CORS Issue: from Shopify demo store via my theme extension to Remix App Hosted apis on my VPS

attaboiaj
Shopify Partner
22 4 4
"Shopify demo store via my theme extension like a form submit" : Refer as X
 
I'm encountering a persistent CORS issue when trying to make API calls from my X to a Remix-based backend hosted on Zerops. I've tried several approaches, but none have resolved the issue. Here are the details:
 
Problem:
When I make a POST request from my X (origin: https://MY_DEV_TEST_STROE.myshopify.com) to my API endpoint (example.zerops.app/api/analytic), I receive the following CORS error:

```
Access to fetch at 'example.zerops.app/api/analytic' from origin 'https://MY_DEV_TEST_STROE.myshopify.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```

What I've Tried:
1. The API works fine when tested with Postman, Thunder Client, and other HTTP clients/Other Frontends
2. I've successfully set up a similar API using Express and hosted it on Vercel, which works without CORS issues.
3. I've attempted to add CORS headers in my Remix action functions, but the issue persists.
4. Tried everything using this https://community.shopify.com/c/online-store-and-theme/cors-issue-when-requesting-data-from-shopify-...
5. YES I tested Proxy settings but seems like its for "When you wanna call external API from Shopify admin" not from X
6. I tested it with AWS instance same issue 

Tech Stack:
- Frontend: Shopify App
- Backend: Remix
- Hosting: Zerops


Questions:
1. Are there any VPS-specific configurations needed to allow CORS?
2. How can I properly set up CORS in a Remix app hosted on Zerops to allow requests from my Shopify app?
3. Are there any known issues or limitations with CORS when using Remix on Zerops?

Any insights, solutions, or best practices for handling CORS in this scenario would be greatly appreciated. Thank you in advance for your help!




Accepted Solution (1)

attaboiaj
Shopify Partner
22 4 4
Reply 1 (1)

attaboiaj
Shopify Partner
22 4 4

This is an accepted solution.