1
我嘗試從前端(angular2)發送請求到後端(ruby,sinatra)。 現在,兩個服務器的工作在一臺計算機上(在localhost角:3001,特拉在localhost:9292)從angular2發送到後端的請求
我使用AUTH的例子(http://embed.plnkr.co/TIPmK3/?show=preview),並希望將用戶數據發送到屈。
我看到有趣的字符串app/_services/authentication.service.ts
:
return this.http.post('/api/authenticate', JSON.stringify({ username: username, password: password }))
.map((response: Response) => {...}
但如果http://localhost:9292/login
沒有更換'/api/authenticate'
發生。請求不發送,沒有錯誤。只加載。
任何人都可以幫助我嗎?
謝謝你的answear。是的,我在後端設置了標頭['Access-Control-Allow-Origin'] ='*',但在後端沒有角度請求。 – Flamine
你會請嘗試打電話 this.http.post('localhost:9292/api/authenticate',...... –
它不工作。我的後端不能在這條路線上請求,但現在,登錄頁面在我登錄點擊後沒有睡覺,並且沒有在後臺登錄請求。 – Flamine