Saturday, March 17, 2018

Request header field Content-Type is not allowed by Access-Control-Allow-Headers in flight response - development

Request header field Content-Type is not allowed by Access-Control-Allow-Headers in flight response

i am developing angular 4 application with laravel (Restful Api). i have test the api with postman its working fine but when i call the api from angular 4 i am getting this error.

enter image description here

import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';
import { User } from '../models/user';
import 'rxjs/add/operator/toPromise';

@Injectable()
export class AuthService {
 private BASE_URL: string = 'http://localhost/fmfb_hr/public/api';
  private headers: Headers = new Headers({'Content-Type': 'application/json'});
 constructor(private http: Http) {}
login(user): Promise<any> {
let url: string = `${this.BASE_URL}/login`;
return this.http.post(url, user, {headers: this.headers}).toPromise();
}

}



from Laravel Questions and Answers https://laravelquestions.com/php/request-header-field-content-type-is-not-allowed-by-access-control-allow-headers-in-flight-response/
via Lzo Media

No comments:

Post a Comment