My problem is that I’m developing an app in shopify remix. When I run script npm run dev. It gives me a local url to check my changes.
On that url I have route where my main products will display.
What happening here is that I’m geeting cors error while opening that url.
It sounds like your local server (localhost) is trying to access resources from another origin (Heroku), which is causing the CORS error.
Here are a few solutions you can try:
Enable CORS in your Heroku app: The server where you host your app should have CORS enabled. If you’re using Express.js, you can use the cors middleware to enable CORS. ``
Configure Shopify App Bridge:Shopify App Bridge provides a middleware that adds necessary headers to your responses to enable communication between your embedded app and Shopify Admin.
Use a Proxy to Avoid CORS: If you can’t enable CORS in your server or the Shopify App Bridge doesn’t work for you, another option is to set up a proxy server. The proxy server makes the requests to the other origin on behalf of your app.
Try the above options and let us know if you’re still running into issues.