Click here to Skip to main content
14,237,414 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have created a webapi with jwt authentication. I am able to get response without authorization, when i have added authorize attribute to controller, its giving me unauthorized which is correct. But when i sent authorization header its giving CORS error and request not working. Is there any attribute i need to send?

this.httpOptions = {
           headers: new HttpHeaders({
               'Content-Type': 'application/json',
               'Authorization': 'Bearer '+ this.readCookie()

       return this.http.get("http://localhost:50507/api/employee").toPromise();


What I have tried:

Tried with $.ajax getting same error.
Mada Naga Sankar 8-Jun-18 6:49am
Code edit : return this.http.get("http://localhost:50507/api/employee", this.httpOptions).toPromise();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100