"访问控制允许来源"连接到Amazon Product Advertising API时出错

时间:2018-02-13 19:56:58

标签: javascript amazon-web-services

我试图通过javascript访问亚马逊产品广告API,但无论我是使用axios还是像apac这样的一体化解决方案,我都会得到一个"访问控制 - 允许来源"错误。我在亚马逊的文档中没有看到如何解决这个问题。

这是错误:

No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access. 
If an opaque response serves your needs, set the request's mode 
to 'no-cors' to fetch the resource with CORS disabled.

我也看到无处记录如何将请求模式设置为“无人”的情况。有没有人有解决方法呢?

1 个答案:

答案 0 :(得分:4)

此API旨在供服务器端应用程序使用。它不是为Javascript应用程序设计的 - 这样的用法是不安全的,因为您将API密钥暴露给客户端。