我正面临这个错误,有人可以指导我吗?我已经在 proxy.conf.json 中进行了配置我已经在 user.service.ts 中设置了带有基本 url 的标头
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import { map } from 'rxjs/operators';
@Injectable()
export class UserService {
constructor(public http: Http) { }
yaho() {
const headers = new Headers();
headers.append('Access-Control-Allow-Origin', '*');
// headers.append('Access-Control-Allow-Credentials', 'true');
headers.append('Access-Control-Allow-Headers', 'Content-Type');
headers.append('Access-Control-Allow-Methods', 'GET, POST');
headers.append('Content-Type', 'application/json');
headers.append('appKey', '4d71e017-6896-477b-bb0d-93bb9e6d3224');
const options = new RequestOptions({ headers });
const baseURL = 'abx/gas.json';
console.log('Base url---->' + baseURL);
const url = 'localhost:8081/abx/gas.json';
return this.http.get(url, options)
.pipe(map(res => res.json()));
}
}