-1
我在下面的代碼中寫下從其他域下載.CSV文件的代碼。如何解決離子2中的CORS起源問題
const fileTransfer: TransferObject = this.transfer.create();
let url = 'http://example.com' + data.filepath;
console.log(url);
fileTransfer.download(url, this.file.dataDirectory + 'Sample.csv').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
console.log("No file to download");
});
它給了我下面的錯誤
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com/sample.csv (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
我正在使用'離子視圖'應用程序來測試設備上的'MyApp',但是當我點擊下載按鈕時什麼也沒有發生。沒有文件下載。 –