Follow by Email

Tuesday, November 29, 2016

Origin http://localhost:4200 not found in Access-Control-Allow-Origin header.

Problem
In my angularjs 2 application I am using a restful service

http://jsonplaceholder.typicode.com/users

When I try to call this service I get below error

Origin http://localhost:4200 not found in Access-Control-Allow-Origin header.

All solutions were suggesting to add  No 'Access-Control-Allow-Origin' header which was not an option for me because I had no control on the server.

Reason
For my case the reason was the network (My office network) to which I was connected it was not allowing this port for some reason.

Solution

Changed the network and it was working fine :).