React 中如何处理 CORS
How to deal with CORS in React
我已经使用模块 amazon-product-api
编写了我调用亚马逊产品 API 的 React 应用程序,但它给了我 CORS 问题。
我收到跟随错误
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.
对于临时解决方案,我添加了 cors 扩展以使其正常工作。
amazon-product-api
是亚马逊产品广告 API 的 Node.js 客户端, 应在服务器端使用 。
如果您在客户端使用 React,这就是您遇到 CORS 问题的原因。
我已经使用模块 amazon-product-api
编写了我调用亚马逊产品 API 的 React 应用程序,但它给了我 CORS 问题。
我收到跟随错误
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.
对于临时解决方案,我添加了 cors 扩展以使其正常工作。
amazon-product-api
是亚马逊产品广告 API 的 Node.js 客户端, 应在服务器端使用 。
如果您在客户端使用 React,这就是您遇到 CORS 问题的原因。