我試圖發送一個文件使用aurelia-fetch-client
服務器,而是要在瀏覽器控制檯下面的錯誤。 No 'Access-Control-Allow-Origin' header is present on the requested resource.
,但是當我和XMLHttpRequest
文件一樣上傳時。奧裏利亞JS後的二進制數據到服務器
奧裏利亞獲取客戶端的配置和使用代碼
activate() {
await fetch;
this.http = this.httpClient();
this.http.configure(config => {
config
.useStandardConfiguration()
.withBaseUrl('http://localhost:3000')
});
}
makeRequest(data) {
this.http.fetch('upload', {
headers: {
'Content-Type': 'multipart/form-data'
},
method: 'post',
body: data
});
}
好像你還沒有你的服務器上配置CORS? – Darxtar
嗨,我需要做同樣的事情,但無法找到解決方案。任何更新@llia和我的問題是在[鏈接](http://stackoverflow.com/questions/39991277/aurelia-js-fie-upload-to-server) – sibi
@Darxtar你是對的,因爲我使用節點服務器我必須配置cors。 @sibi如果你正在使用'express',你可以使用cors-express模塊 –