首页 文章

预检请求没有't pass access control check: No ' Access-Control-Allow-Origin'

提问于
浏览
-1

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 回答

  • 0

    转到您尝试发送表单信息的服务器,以允许 content-type 并允许 origin from 您发送信息的来源,例如从 http://frontend.com 发送信息到 backend.com ,您需要将 http://frontend.com 添加到您的后端 origin 以允许请求从该来源,否则它将不允许来自该来源 .

    如果您使用的是后端框架,请务必检查其 CORS 设置

相关问题