阿里云函数计算的SDK没有在浏览器环境中的实现,当使用HTTP触发且配置了签名校验时,需要自己实现加签算法。
npm i @chongho/aliyun_fc_web_sdk
import Client from "@chongho/aliyun_fc_web_sdk";
const client = new Client({
accessKeyID: "<your accessKeyID>",
accessKeySecret: "<your accessKeySecret>",
});
const signedHeaders = client.getSignedHeaders('get', '<your FC path>')
// use SDK send request
client.get('<your FC http trigger URL>')
// use custom request lib send request
fetch('<your FC http trigger URL>', {
method: 'get',
headers: signedHeaders
})