Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

Access-Control-Allow-Origin

XMLHttpRequest cannot load http://localhost:60712/api/Default. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.

running ng serve   http://localhost:4200/

Not sure what to do.  I just want to test for local development.

I did the npm install ember-cli-cors
I added Cors to mvc project.
my headers in my angularCli project looks like
constructor(private _http: Http) { }
  getUserAdminID(): Observable<any[]> {
        let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'false','Access-Control-Allow-Methods': 'GET,HEAD,OPTIONS,POST,PUT',
            'Access-Control-Allow-Headers': 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Content-Type' });

        let options = new RequestOptions({ headers: headers });
        return this._http.get(this._data, options)
            .map((response: Response) => <any[]>response.json())
             .catch((error: any) => Observable.throw(error.json().error ))//|| this.showError()
                .do(data => console.log('List: ' + JSON.stringify(data)));

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

tks