Hi
I’m new here and excited to learn coding with you guys.
I’m currently learning angular and I have an issue with deploying my app to a centOS server running on nginx.
The backend and APIs of the app I am developing is on the same server but I keep getting an error while I try to login.
I am only working on the frontend and my colleague who developed the backend assures me the API is fine.
He also assured me that he’s added the cors policy on his backend (springboot).
Please help…
Kindly find attached code snippets and screenshot of said errors. Any assistance would be really appreciated and thanks in advance…
//environment.ts file
export const environment = {
production: false,
baseUrl: 'http.test.blink.co.ke/api/v2',
};
//code on authentication service
login(email: string, password: string) {
return this.http.post<any>(
`${environment.baseUrl}/admin/auth/login`, { email, password }, { headers: this.headers })
.pipe(map((response: any) => {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('currentUser', JSON.stringify(response));
this.currentUserSubject.next(response);
console.warn(response)
return response;
}));
//code on login.ts file
onSubmit() {
this.authService.login(this.loginForm.value.email, this.loginForm.value.password).subscribe(
data => {
// alert(JSON.stringify(data));
if (data) {
this.alertService.success('Success!!', this.options)
this.route.navigate(['/admin/dashboard'])
} else {
this.alertService.error('Error!!', this.options);
}
// this.authService.generateToken().subscribe(data => {});
});