-1

I use Jersey RESTful Web as a server and want to communicate with angular. Each HTTP request I try to send creates the following problem:

Access to XMLHttpRequest at 'http://localhost:8080/CouponSystemJersey/login?password=1234&loginType=ADMIN&userName=admin' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I know the problem is that anguler and web service projects are in the same local host, but I know it has a solution..

I would be happy for any help.

1 Answers1

0

This happens because your angular app and your server app are hosted on different origins, to fix this you need to host them on one origin (locally you can use proxy), or you need to enable CORS on your web server. Hope that helps.

Amir Arbabian
  • 3,419
  • 1
  • 6
  • 12