2015-10-27 82 views
1

我正在開發一個Firefox附加組件,我無法從彈出腳本發送請求。它顯示了一些錯誤Firefox附加啓用CORS域請求

Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

在擴展鉻擴展工作正常。

彈出腳本

$.ajax({ 
    url: 'http://localhost/api/user/66f041e16a60928b05a7e228a89c3799/emailtemplate/c60d870eaad6a3946ab3e8734466e532', 
    type: 'GET', 
    dataType: 'json', 
    headers: { 'accessToken': 'Krc7YPoZPaYiy37O', 'appID': '28fdd9c013e37bca7dd875b10817b694', 'appSecret': '15798907115476fdf1de7a8' }, 
    success: function(eventSettingsResponse) { 
     buildTemplate(eventDetailsResponse, eventSettingsResponse); 
     console.log('This is content script testing...', eventDetailsResponse); 
    }, 
    error: function() { } 
    //beforeSend: setHeader 
}); 

的package.json

{ 
"title": "First", 
"name": "test", 
"version": "0.0.1", 
"description": "Just for testing", 
"main": "index.js", 
"author": "Bharath", 
"engines": { 
    "firefox": ">=38.0a1", 
    "fennec": ">=38.0a1" 
}, 
"permissions": { 
"cross-domain-content": ["http://localhost/*"] 
}, 
"license": "MIT" 
} 

Main.js

pageMod.PageMod({ 
include: ["https://mail.google.com/*"], 
contentScriptFile: data.url("js/content.js"), 
contentScriptWhen: 'end', 
onAttach: function(worker) { 
worker.port.emit("init", urls); 
worker.port.on("showPopup", function() { 
    console.log('port received'); 
    windows.open(data.url('popup/popup.html'), { 
     name: 'jetpack window', 
     features: { 
      width: 500, 
      height: 500, 
      popup: false 
     } 
    }); 
}); 
    worker.port.on("returnHtml", function() { 
     console.log('Html returnde.'); 
    }); 
} 
}); 

回答

0

我讀here,我可以添加以下的package.json

"permissions": { 
     "cross-domain-content": ["https://data.com"] 
    }