XML HTTP Request Authentication error "blocked by CORS policy" - angular -
i trying display information web server in angular app , error appears when running. because username & password needed access application.
error: xmlhttprequest cannot load http://... redirect 'http://...' 'http://.../login.html' has been blocked cors policy: no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:4200' therefore not allowed access. how can provide within code loads? code:
project.viewer.component.ts:
@component({ selector: 'project-viewer', template: `<h1>projects</h1> <pre>{{projects}}</pre>`, styleurls: ['./app.component.css'] }) export class projectviewercomponent { name = 'projectviewercomponent'; projects: string; errormessage = ""; statevalid = true; constructor(private http:http) { this.http.get("http://link/projects") .map(resp => resp.text()) .subscribe(jsonastext => this.projects = jsonastext); } } how authenticate within code? in advance.
Comments
Post a Comment