Access-Control-Allow-Headers策略阻止了自己主机内的通信

时间:2016-12-27 23:28:26

标签: typescript

我正在尝试发送http请求,但我面对标题中提到的错误它如此常见但我怎么能在我的Ts组件中处理它(调用makecall()函数):

import { Component,OnInit, ViewEncapsulation } from '@angular/core';
import {DomSanitizer } from "@angular/platform-browser";
import {Http, Response, Headers} from '@angular/http';
@Component({
  selector: 'app-twitter',
  templateUrl: '../templates/twitter.component.html',
  styleUrls: ['../styles/twitter.component.css'],
  encapsulation:ViewEncapsulation.None
})
export class TwitterComponent {
  constructor(private  domSanitizer : DomSanitizer, private http_:Http){
  }

  makecall() {
    var headers = new Headers();
    headers.append('Content-Type', 'application/X-www-form-urlencoded');
    this.http_.post('http://localhost:3000/authorize', {headers: headers}).subscribe((res) => {
      console.log(res);
    })
  }
}

这是我在开发控制台中看到的: enter image description here

0 个答案:

没有答案