Click here to Skip to main content
15,887,421 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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();


Thanks

What I have tried:

Tried with $.ajax getting same error.
Posted
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900