如何在FireFox插件(扩展)中使用AWS JavaScript SDK [英] How to use AWS JavaScript SDK in FireFox Addon (Extension)
问题描述
我编写了一个非常简单的脚本,仅记录了EC2实例的列表:
I've written a very simple script that just logs the list of EC2 instances:
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
})
将此脚本添加到HTML文件(使用aws-sdk-2.409.0.js
脚本).一切正常.
但是,当我在FireFox扩展中使用相同的代码时,会得到:
Added this script to an HTML file (with aws-sdk-2.409.0.js
script). Everything works just fine.
But when I use the same code in a FireFox extension I get:
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
我在Google上搜索并发现了一些有关CORS的问题(所有问题都与S3兼容).有人知道我如何在FireFox扩展中使用AWS开发工具包来完成简单的工作,例如列出EC2实例等吗?
I googled and found some issues regarding CORS (all working with S3). Does anybody know how I can use AWS SDK in a FireFox extension to do simple stuff like listing EC2 instances, etc?
推荐答案
这是由于扩展的清单文件中缺少permissions
条目引起的:
It was due to missing permissions
entry in the manifest file of the extension:
"permissions": [
"https://*.amazonaws.com/*"
]
这篇关于如何在FireFox插件(扩展)中使用AWS JavaScript SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!