Search code examples
javascriptreactjscorsamazon-product-api

How to deal with CORS in React


I have wrote the react app from which i am calling the amazon-product API using the the module amazon-product-api but it gives me CORS issue.

I am getting Following error

Failed to load https://webservices.amazon.in/onca/xml?AWSAccessKeyId=aasc&AssociateTag=asd&Condition=All&Domain=webservices.amazon.in&IdType=ASIN&IncludeReviewsSummary=True No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

For temporary solution i have added cors extension to get the things work.


Solution

  • amazon-product-api is a Node.js client for the Amazon Product Advertising API and should be used on the server-side.

    If you're using it on the client-side with React, that's the reason you get the CORS issue.