login(user:any){console.log(user); const body = username=${user.username}&password=${user.password}
; const headers = new Headers(); headers.append('Content-Type','application/x-www-form-urlencoded'); return this.apiService.post(this.url,body,headers); }
1 回答
转到您尝试发送表单信息的服务器,以允许
content-type
并允许origin from
您发送信息的来源,例如从http://frontend.com
发送信息到backend.com
,您需要将http://frontend.com
添加到您的后端origin
以允许请求从该来源,否则它将不允许来自该来源 .如果您使用的是后端框架,请务必检查其 CORS 设置