我在appache服務器上部署的球衣一個Web服務,我試圖連接到該服務器,但我得到了以下錯誤:無法與REST Web服務連接
Failed to load http://192.168.1.200:8199/CheckinnWeb/webapi/myresource/query: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
我service.ts文件代碼如下
getlogin(): Observable<ILogin[]> { \t \t \t
\t \t return this._http
.get(this._loginurl, this.headers)
.map((response: Response) => <ILogin[]> response.json())
.catch(this.handleError);
}
這是我的服務器的URL
_loginurl='http://192.168.1.200:8199/CheckinnWeb/webapi/myresource/'+this.encodedString;
請幫我解決這個問題..謝謝!!
是什麼'this.encodedString'?看起來像一個SQL查詢我 – Niladri
看起來像一個CORS問題給我。您是否曾嘗試向'this.headers'添加'Access-Control-Allow-Origin'請求標頭?檢查apache託管服務是否允許跨域請求 – Niladri
這不是一個明確的問題!你應該提供更多的細節。 因爲我看到這是你的端點「... webapi/myresource」 ,這是你的參數「select ....」我是對嗎?如果這不是一個參數,那麼使用?請求參數! 問題出在您的端點上, 您能調試您的端點嗎? 你的服務網址迴應什麼? –