I am trying to post data to server. My php side is working fine. When I tried using postman post is working. But from angular I am getting 405 (Method Not Allowed) error:
zone.js:2935 OPTIONS http://angularslim.local/public_html/users 405 (Method Not Allowed)
Failed to load http://angularslim.local/public_html/users: Response for preflight has invalid HTTP status code 405
.
My codes are below: Inside my service I have following code.
@Injectable()
export class AuthService {
constructor(private http: Http) {}
register(user:User){
this.http.post("http://angularslim.local/public_html/users", user).subscribe((res: Response) => {
console.log("inside");
})
}
And in my php section I do have these lines
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");