Focuses on API authentication, access scopes, and permission management.
Hi Mohdyou,
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.
Since you do not have any backend, you might want to consider using serverless functions (like Vercel or Netlify functions) to handle these kinds of tasks.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello Liam,
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
Mohd Shahrukh
Hey,
Can you please guide me to resolve this issue.
Thank you