I have a Laravel backend, which allows me to manage the user. I tested the backend with Postman. I could create a user and log in. Now I want to log in with Angular. However, I get a 500th So that's not much start. I have the feeling that it is a header problem. But I do not know why.
my backend here:
https://github.com/TheSlowlySnail/MT_Backend_Iventorysystem
here my service:
httpOptions = {
headers: new HttpHeaders({
/* 'Content-Type': 'application/json', */
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded'
})
};
constructor(private http: HttpClient) { }
signup(username: string, email: string, password: string, c_password: string) {
return this.http.post('http://127.0.0.1:8000/api/userRegister', { name: username, email: email, password: password,
c_password: c_password },
this.httpOptions).subscribe(
respone => { console.log(respone); }
);
}
here my crontroller:
constructor(private authService: AuthService) { }
ngOnInit() {
}
onSignup(form: NgForm) {
this.authService.signup(form.value.username, form.value.email, form.value.password, form.value.c_password);
}
Error message:
Failed to load http://127.0.0.1:8000/api/userRegister: Response for preflight has invalid HTTP status code 500.
Backend by this tutorial
https://itsolutionstuff.com/post/php-laravel-56-rest-api-with-passport-tutorialexample.html
I do not know how to continue. I have also looked at similar problems, where I've also tried a lot. Unfortunately without success.