Even if your application is mostly client-side, for tasks that involve calling APIs, you should have a server-side component to your app that securely stores your credentials and makes requests to the Shopify API. The frontend of your application can then make requests to your own backend, which in turn calls the Shopify API and returns the response back to your frontend. This way, the actual call to Shopify's API is made server-side, avoiding CORS issues and keeping your credentials secure.
Hope this helps!
I tried using vercel for the deployment of my code.
I am getting below error:
"Access to fetch at 'https://croquet-microverse.myshopify.com/admin/api/2023-04/products.json' from origin 'https://croquet-microverse-9n1n9r8js-soni-shivani.vercel.app' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
also I tried to resolve this by adding this code in my API call
I have also attached my code's screenshot please check.
Thanks & regards