[英]How to use AWS JavaScript SDK in FireFox Addon (Extension)
I've written a very simple script that just logs the list of EC2 instances: 我编写了一个非常简单的脚本,仅记录了EC2实例的列表:
AWS.config.update({accessKeyId: 'id', secretAccessKey: 'secret', region: 'region'});
var ec2 = new AWS.EC2();
ec2.describeInstances({}, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
})
Added this script to an HTML file (with aws-sdk-2.409.0.js
script). 将此脚本添加到HTML文件(带有
aws-sdk-2.409.0.js
脚本)。 Everything works just fine. 一切正常。 But when I use the same code in a FireFox extension I get:
但是,当我在FireFox扩展中使用相同的代码时,会得到:
NetworkingError: "Network Failure"
handleRequest moz-extension://uuid/aws-sdk-2.409.0.js:155410
[300]</handleRequest/<@moz-extension://uuid/aws-sdk-2.409.0.js:155410:34
I googled and found some issues regarding CORS (all working with S3). 我在Google上搜索,发现了一些有关CORS的问题(所有问题都与S3兼容)。 Does anybody know how I can use AWS SDK in a FireFox extension to do simple stuff like listing EC2 instances, etc?
有谁知道我如何在FireFox扩展中使用AWS开发工具包来完成简单的工作,例如列出EC2实例等?
It was due to missing permissions
entry in the manifest file of the extension: 这是由于扩展的清单文件中缺少
permissions
条目所致:
"permissions": [
"https://*.amazonaws.com/*"
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.