-1
我正在從AWS網關創建一個JavaScript SDK來調用我的api。我曾嘗試添加多個標題,這是我遇到的文檔和網頁。但我找不到解決方案。我使用Facebook驗證用戶身份,並且我擁有使用python的api。如何解決api網關中的cors問題
AWS.config.region = region';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: identityPoolId ,
Logins: {
'graph.facebook.com':fbTokenId
}
});
AWS.config.credentials.get(function(){
var identityId = AWS.config.credentials.identityId;
var accessKeyId = AWS.config.credentials.accessKeyId;
var secretAccessKey = AWS.config.credentials.secretAccessKey;
var sessionToken = AWS.config.credentials.sessionToken;
apigClient = apigClientFactory.newClient({
accessKey: accessKeyId,
secretKey: secretAccessKey,
sessionToken: sessionToken,
//region: region
});
apigClient.rootGet({},{},{})
.then(function(result){
// Add success callback code here.
console.log("result : ");
console.log(result);
}).catch(function(result){
// Add error callback code here.
console.log(result);
});
這是我在控制檯中看到的錯誤。 加載資源失敗:服務器響應狀態爲403(禁止) index.html:1 XMLHttpRequest無法加載https://####.us-west-2.amazonaws.com/####/。請求的資源上沒有「Access-Control-Allow-Origin」標題。因此不允許原產地'null'訪問。該響應具有HTTP狀態碼403.感謝提前的幫助。