I am having some trouble allowing cors. I have set server side
like so:
app.UseCors(builder => builder.WithOrigins("http://localhost:4200/").AllowAnyHeader());
Inside of the configure
method of the startup
class
When the my web API is hit, it will return the data fine.
However, the problem seems to be with Angular as in the I get the following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
Here is my angular web api call
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';;
@Injectable()
export class ProfileService {
private baseUrl = 'api/profile/';
constructor(private http: HttpClient) { }
getLookups(step: number) {
return this.http.get('http://localhost:51658/' + this.baseUrl + 'lookups/' + step)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With